Barn Echoes
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and returns. She is curious as to just how much overlap there is.
Given two lines of input (letters from the set a..z, total length in the range 1..80), each of which has the wording of a moo on it, determine the greatest number of characters of overlap between one string and the other. A string is an overlap between two other strings if it is a prefix of one string and a suffix of the other string.
By way of example, consider two moos:
     moyooyoxyzooo
     yzoooqyasdfljkamo
The last part of the first string overlaps 'yzooo' with the first part of the second string. The last part of the second string overlaps 'mo' with the first part of the first string. The largest overlap is 'yzooo' whose length is 5.
POINTS: 50

输入描述:

* Lines 1..2: Each line has the text of a moo or its echo

输出描述:

* Line 1: A single line with a single integer that is the length of the longest overlap between the front of one string and end of the other.
示例1

输入

复制
abcxxxxabcxabcd 
abcdxabcxxxxabcx 

输出

复制
11

说明

'abcxxxxabcx' is a prefix of the first string and a suffix of the second string.