public int minDistance(String word1, String word2) {
		int n = word1.length();
		int m = word2.length();

		int Edit[][] = new int[n + 1][m + 1];

		for (int i = 0; i <= n; i++)
			Edit[i][0] = i;
		for (int i = 0; i <= m; i++)
			Edit[0][i] = i;

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (word1.charAt(i - 1) == word2.charAt(j - 1))
					Edit[i][j] = Edit[i - 1][j - 1];
				else
					Edit[i][j] = Math.min(Edit[i - 1][j - 1],
							Math.min(Edit[i - 1][j], Edit[i][j - 1])) + 1;
			}
		}
		return Edit[n][m];
	}