#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  unsigned long long n;
  cin >> n;
  char f;
  cin >> f;
  unsigned long long h;
  if (f == 'f') h = 1;
  if (f == 'e') h = 2;
  if (f == 'd') h = 3;
  if (f == 'a') h = 4;
  if (f == 'b') h = 5;
  if (f == 'c') h = 6;
  cout << ((n - 1) / 4) * 16 + h + ((n + 1) % 2) * 7;
  return 0;
}
