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