public int search(String docs) {
		int N = docs.length();
		long docsHash = hash(docs, M);
	
		if (docsHash == patternHash) return 0;
		
		for (int i = M; i < N; i++) {
			// remove leading digit
			docsHash = (docsHash + Q - RM * docs.charAt(i-M) % Q) % Q;
			// add trailing digit
			docsHash = (docsHash * R + docs.charAt(i)) % Q;
			
			// match
			if (patternHash == docsHash) return i - M + 1;
		}
		
		return N;
	}