Prefixes and suffixes P33597


Statement
 

pdf   zip

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.

Public test cases
  • Input

    a b
    z z
    barbacoa acabar
    cabar abacar
    cabar acabat
    cabar acabar
    abacad ababa
    acad academiacad
    

    Output

    0
    1
    3
    0
    0
    5
    3
    4
    
  • Information
    Author
    Alex Alvarez
    Language
    English
    Official solutions
    C++
    User solutions
    C++