#include <bits/stdc++.h>
using namespace std;
map<char, int> cnt;
int main() {
  cnt['f'] = 1;
  cnt['e'] = 2;
  cnt['d'] = 3;
  cnt['a'] = 4;
  cnt['b'] = 5;
  cnt['c'] = 6;
  string w;
  cin >> w;
  long long n = 0;
  char seat = w[w.size() - 1];
  for (int i = 0; i + 1 < w.size(); i++) {
    n = n * 10;
    n += (w[i] - '0');
  }
  long long ans = 16LL * ((n - 1) / 4);
  long long row = n % 4;
  if (row == 1 || row == 3) {
    ans += cnt[seat];
  }
  if (row == 2 || row == 0) {
    ans += 7LL + cnt[seat];
  }
  cout << ans << endl;
  return 0;
}
