#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
int main() {
  m['a'] = 4;
  m['b'] = 5;
  m['c'] = 6;
  m['d'] = 3;
  m['e'] = 2;
  m['f'] = 1;
  long long n;
  char c;
  cin >> n >> c;
  cout << (n - 1) / 4 * 16 + (n + 1) % 2 * 7 + m[c] << endl;
  return 0;
}
