public int numDistinct(String S, String T) {
		// Start typing your Java solution below
		// DO NOT write main() function
		if (S.length() == 0 || S.length() < T.length()) {
			return 0;
		}
		if (T.length() == 0) {
			return 1;
		}
		int[][] dp = new int[S.length() + 1][T.length() + 1];
		for (int j = 0; j <= T.length(); j++) {
			dp[0][j] = 0;
		}
		for (int i = 0; i <= S.length(); i++) {// dp[0][0]==1
			dp[i][0] = 1;
		}

		for (int j = 1; j <= T.length(); j++) {
			for (int i = 1; i <= S.length(); i++) {
				if (S.charAt(i - 1) == T.charAt(j - 1)) {
					dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}

		return dp[S.length()][T.length()];

	}