Prefixes and suffixes

Given two strings ss and tt, print the maximum kk such that the prefix of length kk of ss is equal to the suffix of length kk of tt.

Input

Input consists of several cases, each one with ss and tt. Every string is made up of between 1 and 10610^6 lowercase letters.

Output

For every case, print kk.

Problem information

Author: Alex Alvarez

Generation: 2026-01-25T10:18:26.608Z

© Jutge.org, 2006–2026.
https://jutge.org