#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e+5;
const int MOD = 1e9 + 7;
string s;
int main() {
  int n;
  char c1, c2;
  while (cin >> s) {
    int len = s.length();
    char seat = (s[len - 1]);
    string ss(s.begin(), s.end() - 1);
    stringstream st;
    st << ss;
    long long row;
    st >> row;
    int a = 0, ord = 0;
    if (row % 4 == 0 || row % 4 == 3) {
      a = 2;
      if (row & 1)
        ord = 1;
      else
        ord = 2;
    } else {
      a = 1;
      if (row & 1)
        ord = 1;
      else
        ord = 2;
    }
    long long ans = 0;
    long long r = (row - 1) / 4;
    ans += (long long)r * 12;
    if (r >= 1) ans += (long long)r * 4;
    if (ord > 1) ans += 7;
    if (seat == 'f')
      ans += 1;
    else if (seat == 'e')
      ans += 2;
    else if (seat == 'd')
      ans += 3;
    else if (seat == 'a')
      ans += 4;
    else if (seat == 'b')
      ans += 5;
    else if (seat == 'c')
      ans += 6;
    cout << ans << endl;
  }
  return 0;
}
