private int getNumPages(Configuration conf, Path titlesDir)
			throws Exception {

		int numPages = 0;

		IntWritable pageNumber = new IntWritable();
		MapFile.Reader[] readers = MapFileOutputFormat.getReaders(titlesDir, conf);
		for (int i = 0; i < readers.length; i++) {
			readers[i].finalKey(pageNumber);
			if (pageNumber.get() > numPages) {
				numPages = pageNumber.get();
			}
		}
		for (MapFile.Reader reader : readers) {
			reader.close();
		}

		return numPages;
	}