#include <bits/stdc++.h>
using namespace std;
string st;
int main() {
  long long ll, i, j;
  long long n = 0, ans = 0, k = 0;
  cin >> st;
  ll = st.size();
  for (i = 0; i < ll - 1; i++) {
    n = n * 10 + st[i] - '0';
  }
  k = n % 4;
  ans = n / 4;
  if (k == 0) ans--;
  ans = ans * 16;
  if ((k == 2) or (k == 0)) ans += 7;
  if (st[ll - 1] == 'e')
    ans++;
  else if (st[ll - 1] == 'd')
    ans += 2;
  else if (st[ll - 1] == 'a')
    ans += 3;
  else if (st[ll - 1] == 'b')
    ans += 4;
  else if (st[ll - 1] == 'c')
    ans += 5;
  cout << ans + 1 << "\n";
  return 0;
}
