#include <bits/stdc++.h>
using namespace std;
int arr[1000009], brr[1000009];
int main() {
  long long int ager_cover, n, one, two;
  char ch;
  map<char, int> mp;
  mp['f'] = 1;
  mp['e'] = 2;
  mp['d'] = 3;
  mp['a'] = 4;
  mp['b'] = 5;
  mp['c'] = 6;
  cin >> n >> ch;
  if (n % 4 == 0 || n % 4 == 3) {
    two = n - 3;
    ager_cover = (n - 3) / 2;
    if ((n - 3) % 2 != 0) ager_cover++;
    ager_cover *= 6;
    cout << ager_cover + mp[ch] + two << endl;
  } else if (n % 4 == 1 || n % 4 == 2) {
    one = n - 1;
    ager_cover = (n - 1) / 2;
    if ((n - 1) % 2 != 0) ager_cover++;
    ager_cover *= 6;
    cout << ager_cover + mp[ch] + one << endl;
  }
}
