#include <bits/stdc++.h>
using namespace std;
long double PI = acos(-1);
template <class T>
inline const T sqr(const T& x) {
  return x * x;
}
long long popcnt(long long mask) {
  long long cnt = 0;
  while (mask) cnt += mask & 1, mask >>= 1;
  return cnt;
}
long long powi(long long a, long long b, long long mod = 1000000007) {
  if (b < 2) return b ? a : 1;
  return (powi((a * a) % mod, b / 2, mod) * (b % 2 ? a : 1LL)) % mod;
}
long long mod7 = 1000000007;
long long mod9 = 1000000009;
bool isprime(long long n) {
  if (n < 2) return 0;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  string s;
  cin >> s;
  char place = s[s.length() - 1];
  stringstream ss;
  ss << s.substr(0, s.length() - 1);
  long long n;
  ss >> n;
  map<char, int> m;
  m['a'] = 4;
  m['b'] = 5;
  m['c'] = 6;
  m['d'] = 3;
  m['e'] = 2;
  m['f'] = 1;
  n--;
  long long ans = 0;
  ans = (n / 4) * 16LL;
  n %= 4;
  if (n == 1 || n == 3) {
    ans += 7;
  }
  cout << ans + m[place];
  return 0;
}
