#include <bits/stdc++.h>
using namespace std;
struct vt {
  int x, y;
};
int a[100007], b[100007], A[1007][1007];
bool f[100007], cl[1007][1007];
vector<int> g[1007];
int main() {
  int i, j, k, l, n, m;
  string s1, s2, s;
  k = 0;
  long long ta;
  char ba;
  cin >> ta >> ba;
  if (ta % 2 == 0) {
    k += 7;
  }
  if (ba == 'f') {
    k++;
  } else {
    if (ba == 'e') {
      k += 2;
    } else {
      if (ba == 'd') {
        k += 3;
      } else {
        if (ba == 'a') {
          k += 4;
        } else {
          if (ba == 'b') {
            k += 5;
          } else {
            k += 6;
          }
        }
      }
    }
  }
  cout << k + ((ta - 1) / 4) * 16;
  return 0;
}
