1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 10405 - Longest Common Subsequence
* Link:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=16&problem=1346&mosmsg=Submission+received+with+ID+7564977
*
* @author Kratzer Kevin
* @version 1.0, 10/14/2009
*
* Method : Dynamic Programming
* Status : Accepted
* Runtime: 0.116
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main10405 {

public static void main(String...strings) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(true) {
String one = in.readLine();
String two = in.readLine();
if(one == null || two == null)
return;
char[] x = one.toCharArray();
char[] y = two.toCharArray();
int ii = one.length()+1;
int jj = two.length()+1;
int[][] m = new int[ii][jj];
for(int i = 1; i < ii; i++) {
for(int j = 1; j < jj; j++) {
if(x[i-1] == y[j-1]) {
m[i][j] = 1 + m[i-1][j-1];
} else {
m[i][j] = Math.max(m[i-1][j],m[i][j-1]);
}
}
}
System.out.println(m[ii-1][jj-1]);
}
}
}