#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int tmp = 0;
  string ch;
  char seat;
  cin >> ch;
  seat = ch[ch.size() - 1];
  ch.erase(ch.size() - 1, 1);
  unsigned long long int rg;
  stringstream(ch) >> rg;
  if ((rg == 1) || (rg == 3)) {
    tmp = 0;
  } else if ((rg == 2) || (rg == 4)) {
    tmp += 7;
  } else if (rg % 4 == 1) {
    tmp += (rg - 1) + ((rg - 1) / 2) * 6;
  } else if (rg % 4 == 2) {
    tmp += (rg - 1) + ((rg - 1) / 2 + 1) * 6;
  } else if (rg % 4 == 0) {
    tmp += rg - 3 + ((rg - 3) / 2 + 1) * 6;
  } else if (rg % 4 == 3) {
    tmp += rg - 3 + ((rg - 3) / 2) * 6;
  }
  switch (seat) {
    case 'a':
      tmp += 4;
      break;
    case 'b':
      tmp += 5;
      break;
    case 'c':
      tmp += 6;
      break;
    case 'd':
      tmp += 3;
      break;
    case 'e':
      tmp += 2;
      break;
    case 'f':
      tmp += 1;
      break;
  }
  cout << tmp << endl;
  return 0;
}
