public int getMinimum(int nextCost, int prevCost, String start, String goal) {

		int res = -1;
		int n = start.length();
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (!check(start.charAt(i), goal.charAt(i), start.charAt(j),
						goal.charAt(j))) {
					return res;
				}
			}
		}
		res = 0;
		for (int i = 0; i < n; i++) {
			int a = start.charAt(i);
			int b = goal.charAt(i);
			if (a < b) {
				res += nextCost * (b - a);
			} else if (a > b) {
				res += prevCost * (a - b);
			}
		}
		return res;
	}