import java.util.*;
import java.io.*;
/**
 * Write a description of class D1 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class D1
{
    public static void main (String[] args)
    {
        try{
    Scanner fileIn = new Scanner (new File ("DATA1.txt"));
    PrintStream fileOut = new PrintStream( new FileOutputStream("OUT1.txt"));
    for(int lcase = 0; lcase < 5; lcase++){   
        String line[] = new String[2];
        for (int strNum = 0; strNum<2; strNum++)
        {
            line[strNum] = fileIn.nextLine();
        }
        int loc = 0;
        try{
        while (line[0].charAt(loc)==line[1].charAt(loc))
            loc++;
        }
        catch (Exception e)
        {
            
        }
        if (lcase < 4)
        fileOut.println(loc);
        else
        fileOut.print(loc);
    }
}
catch(Exception e)
{
System.err.println(e);
}
}
}

