Prefixes and suffixes

Given two strings s and t, print the maximum k such that the prefix of
length k of s is equal to the suffix of length k of t.

Input

Input consists of several cases, each one with s and t. Every string is
made up of between 1 and 10⁶ lowercase letters.

Output

For every case, print k.

Problem information

Author: Alex Alvarez

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

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