#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  unsigned long long n;
  cin >> n;
  char c;
  cin >> c;
  unsigned long long res;
  if (n % 4 == 1) {
    res = (n / 4) * 2;
  }
  if (n % 4 == 2) {
    res = ((n / 4) * 2) + 1;
  }
  if (n % 4 == 3) {
    res = (n / 4) * 2;
  }
  if (n % 4 == 0) {
    res = (n - 2) / 2;
  }
  unsigned long long serve = res * 6;
  unsigned long long tRows = ((res / 2) * 3) + (res - (res / 2));
  res = serve + tRows;
  if (c == 'a') res += 4;
  if (c == 'b') res += 5;
  if (c == 'c') res += 6;
  if (c == 'd') res += 3;
  if (c == 'e') res += 2;
  if (c == 'f') res += 1;
  cout << res << endl;
}
