#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  map<char, long long> m;
  m['f'] = 1;
  m['e'] = 2;
  m['d'] = 3;
  m['a'] = 4;
  m['b'] = 5;
  m['c'] = 6;
  string s;
  cin >> s;
  long long n;
  char ch;
  stringstream ss(s);
  ss >> n >> ch;
  long long prev = (n - 1) / 4;
  long long ans = 16 * prev;
  if (n % 2)
    ans += m[ch];
  else
    ans += 7 + m[ch];
  cout << ans;
  return 0;
}
