import java.util.Scanner;


public class Main {
	static byte[][] seq;
	static int[] data;
	static int[] pos;
	
	static int calc() {		
		for (int i = 0; i < seq[0].length; i++)
			data[i] = pos[i] = 0;

		for (int j = 0; j < seq[1].length; j++) {
			for (int i = seq[0].length - 1; i >= 0; i--) {
				if (seq[0][i] == seq[1][j]) {
					int max = 0;
					for (int k = 0; k < i; k++)
						max = max < data[k] ? data[k] : max;
					
					data[i] = max + 1;
				}
			}
		}
		
		int max = 0;
		for (int i = 0; i < seq[0].length; i++) {
			max = max < data[i] ? data[i] : max;
		}
		return max;		
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		seq = new byte[2][1000];
		data = new int[1000];
		pos = new int[1000];
		
		while (in.hasNext()) {
			seq[0] = in.nextLine().getBytes();
			seq[1] = in.nextLine().getBytes();
			System.out.println(calc());
		}		
	}
}
