public int search(String docs) {

		int M = pattern.length();
		int N = docs.length();
		
		for (int i = 0; i <= N - M; i++) {
			int skip = 0;
			
			for (int j = M - 1; j >=0; j--) {
				if (pattern.charAt(j) != docs.charAt(i + j)) {
					// calculate skip value
					skip = Math.max(1, j - right[docs.charAt(i + j)]);
					break;
				}
			}
			
			if (skip == 0) return i;
		}
		
		return N;
	}