#include <bits/stdc++.h>
using namespace std;
long long n, m;
char c;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  c = s.back();
  n = 0;
  for (int i = 0; i < s.length() - 1; ++i) n = 10 * n + (long long)(s[i] - '0');
  n -= 1;
  m = (n / 4ll) * 16ll;
  n %= 4ll;
  if (n == 1 || n == 3) m += 7ll;
  if (c == 'a') m += 4;
  if (c == 'b') m += 5;
  if (c == 'c') m += 6;
  if (c == 'd') m += 3;
  if (c == 'e') m += 2;
  if (c == 'f') m += 1;
  cout << m << endl;
  return 0;
}
