#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  char f;
  scanf("%lld%c", &n, &f);
  map<char, int> mp = {{'f', 1}, {'e', 2}, {'d', 3},
                       {'a', 4}, {'b', 5}, {'c', 6}};
  long long rem = n % 4;
  long long full = n / 4;
  long long ans = 0;
  ans += full * 12;
  if (rem == 1 || rem == 2) {
    ans += (n - 1);
  } else {
    ans += (n - 3);
  }
  ans += mp[f];
  if (rem == 0) {
    ans -= 6;
  } else if (rem == 2) {
    ans += 6;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
