Prefixes and suffixes P33597


Statement
 

pdf   zip

thehtml

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 106 lowercase letters.

Output

For every case, print k.

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++