import java.io.*;
import java.util.*;
public class P1{
	public static void main(String [] args)throws IOException{
		String word1, word2;
		int count = 0;
		boolean stillTrue=true;
		Scanner reader = new Scanner(new File("DATA1.txt"));
		PrintWriter writer = new PrintWriter(new File("OUT1.txt"));
		
		while(reader.hasNext()){
			count = 0;
			stillTrue = true;
			word1=reader.nextLine();
			word2=reader.nextLine();
			
			for(int x = 0; x<word1.length()&&x<word2.length()&&stillTrue; x++){
				if(word1.charAt(x)== word2.charAt(x)){
					count++;
				}
				else{
					stillTrue = false;
				}
			}
			writer.println(count);
		}
		
		writer.close();
				
		
	}
}
		
		
	
	
