public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "", line2="";
		StringBuilder sb = new StringBuilder();
		d: do {
			line = br.readLine();
			if (line == null || line.length() == 0)
				break d;
			line2 = br.readLine();
			construc(line, line2);
			lcs(line, line2);
			sb.append(dp[line.length()][line2.length()]).append("\n");
		} while (line != null && line.length() != 0);
		System.out.print(sb);
	}