public int numDistinct(String S, String T) {
		// Note: The Solution object is instantiated only once and is reused by
		// each test case.
		int ls = S.length();
		int lt = T.length();
		int[][] DP = new int[lt + 1][ls + 1];
		for (int i = 0; i <= ls; ++i) {
			DP[0][i] = 1;
		}
		DP[1][0] = 0;
		for (int i = 1; i <= lt; ++i) {
			for (int j = i; j <= ls; ++j) {
				if (S.charAt(j-1) == T.charAt(i-1)) {
					DP[i][j] = DP[i][j - 1] + DP[i - 1][j - 1];
				} else {
					DP[i][j] = DP[i][j - 1];
				}
			}
		}
		return DP[lt][ls];
	}