시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 25 10 10 66.667%

문제

문자열 A의 부분 문자열이란, A에 속하는 하나 또는 그 이상의 문자(연속하지 않아도 된다)를 이용해서 만든 새로운 문자열이다. 이 때, A에서의 순서를 그대로 유지해야 된다.

두 문자열 A와 B가 주어진다. 이 때, A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 문자열 A, 둘째 줄에 문자열 B가 주어진다. 문자열은 알파벳 소문자로만 이루어져 있고, 길이는 1000보다 작거나 같다. 항상 정답이 존재하는 경우만 입력으로 주어진다. 

출력

첫째 줄에 A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열의 길이를 출력한다.

예제 입력 1

ababaa
abbaa

예제 출력 1

3
W3sicHJvYmxlbV9pZCI6IjIxMTIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI0NTAgXHViZDgwXHViZDg0IFx1YmIzOFx1Yzc5MFx1YzVmNCIsImRlc2NyaXB0aW9uIjoiPHA+XHViYjM4XHVjNzkwXHVjNWY0IEFcdWM3NTggXHViZDgwXHViZDg0IFx1YmIzOFx1Yzc5MFx1YzVmNFx1Yzc3NFx1Yjc4MCwgQVx1YzVkMCBcdWMxOGRcdWQ1NThcdWIyOTQgXHVkNTU4XHViMDk4IFx1YjYxMFx1YjI5NCBcdWFkZjggXHVjNzc0XHVjMGMxXHVjNzU4IFx1YmIzOFx1Yzc5MChcdWM1ZjBcdWMxOGRcdWQ1NThcdWM5YzAgXHVjNTRhXHVjNTQ0XHViM2M0IFx1YjQxY1x1YjJlNClcdWI5N2MgXHVjNzc0XHVjNmE5XHVkNTc0XHVjMTFjIFx1YjljY1x1YjRlMCBcdWMwYzhcdWI4NWNcdWM2YjQgXHViYjM4XHVjNzkwXHVjNWY0XHVjNzc0XHViMmU0LiBcdWM3NzQgXHViNTRjLCBBXHVjNWQwXHVjM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