public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		solve();
		while ((line = in.readLine()) != null && line.length() != 0) {
			char[] w = line.trim().toCharArray();
			boolean valid = true;
			for (int i = 1; i < w.length; i++) {
				if (w[i] - 'a' <= w[i - 1] - 'a') {
					valid = false;
					break;
				}
			}
			int ans = valid ? map.get(line) : 0;
			out.append(ans + "\n");
		}
		System.out.print(out);
	}