#include <bits/stdc++.h>
using namespace std;
int s2t[256];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  s2t['f'] = 1;
  s2t['e'] = 2;
  s2t['d'] = 3;
  s2t['a'] = 4;
  s2t['b'] = 5;
  s2t['c'] = 6;
  string str;
  cin >> str;
  char s = str[str.size() - 1];
  long long n = stoll(str.substr(0, str.size() - 1));
  long long ans = (n - 1) / 4 * 16;
  n = (n - 1) % 2;
  ans += 7 * n + s2t[s];
  cout << ans << endl;
  return 0;
}
