A=input() B=input() if len(A)<len(B): l=len(A) else: l=len(B) for i in range(1,l): x=A[-i:] y=B[:i] if x==y: print(l-i) break