#include <bits/stdc++.h>
using namespace std;
long double pi = 3.1415926536;
const long long MOD = 10007;
int main() {
  string s;
  cin >> s;
  long long row = stoll(s.substr(0, s.length() - 1));
  char seat = s[s.length() - 1];
  long long step, time = 0;
  long long rr = row;
  row = row % 4;
  step = (row - 1) / 4;
  long long rem = (row - 1) % 4;
  time = step * 13;
  if (step) {
    time += (step);
  }
  if (step % 2 == 0)
    time += (step);
  else
    time += (step + 1);
  time += ((rr - 1) / 4) * 16;
  if (rem % 2) {
    time += 7;
  }
  if (seat >= 'd') {
    time += ('f' - seat) + 1;
  } else {
    time += abs('a' - seat) + 4;
  }
  cout << time;
}
