#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char seat = s.back();
  s.pop_back();
  long long row = atoll(s.c_str());
  long long rowmem = row;
  if (row % 4 == 0)
    row -= 2;
  else if (row % 4 == 3)
    row -= 1;
  long long ist = (int)seat - 97;
  long long riad = ist >= 3 ? 6 - ist : 4 + ist;
  long long ans = 7 * (row / 4 + 1 - rowmem % 2) + (row / 4) * 9;
  cout << ans + riad;
  return 0;
}
