import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void main ()
{
        string s;
	while ((s = readln.strip) != "")
	{
		char c = s[$ - 1];
		s = s[0..$ - 1];
		long n = s.to !(long);
		n -= 1;
		long full = n / 4;
		long res = full * 16;
		n -= full * 4;
		n %= 2;
		if (n == 1)
		{
			res += 7;
		}
		res += 6 - "fedabc".find (c).length;
		res += 1;
		writeln (res);
	}
}
