private static int check(String x, int base, String y) {
		long sumOfX = sum(x, base);
		char[] cs = y.toCharArray();
		char maxC = '0';
		for(int i = 0; i < cs.length; i++) {
			if(cs[i] > maxC) {
				maxC = cs[i];
			}
		}
		
		long low = d2n(maxC) + 1;
		long high = low + 1;
		if(high < sumOfX + 1) {
			high = sumOfX + 1;
		}
		
		while(low <= high) {
			long mid = (low + high) >> 1;
			long sumOfY = sum(y, (int)mid, sumOfX);
			if(sumOfY > sumOfX) {
				high = mid - 1;
			} else if(sumOfY < sumOfX) {
				low = mid + 1;
			} else {
				return (int)mid;
			}
		}
		return -1;
	}