function Main(input) {
	const col = input.split("\n");
	const T = col[0];
	const S = col[1];

	for(let i = 0; i < S.length; i++){
		if(T.indexOf(S.slice(i)) != -1){
			console.log(S.length - S.slice(i).length)
			break;
		} else {
			if(i != 0 && T.indexOf(S.slice(0, i * -1)) != -1){
				console.log(S.length - S.slice(0, i * -1).length)
				break;
			}
		}
	}
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));