#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, long long int> chairTime;
  chairTime['f'] = 1;
  chairTime['e'] = 2;
  chairTime['d'] = 3;
  chairTime['a'] = 4;
  chairTime['b'] = 5;
  chairTime['c'] = 6;
  long long int numRow;
  char chair;
  cin >> numRow;
  cin >> chair;
  numRow--;
  long long int cycle = 16;
  long long int rowsPerCylcle = 4;
  long long int timeToGetRow = (numRow / rowsPerCylcle) * cycle;
  long long int row = (numRow % 2) * 7;
  long long int timeToChair = timeToGetRow + row + chairTime[chair];
  cout << timeToChair;
}
