#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int pos = s[s.length() - 1] - 'a';
  long long row = 0;
  int i;
  long long pos_time[] = {4, 5, 6, 3, 2, 1};
  for (i = 0; i < s.length() - 1; ++i) row = row * 10 + s[i] - '0';
  long long rows_num = ((row - 1) / 4) * 2;
  if (row % 2 == 0) rows_num++;
  if (row % 4 == 0 || row % 4 == 3)
    row -= 3;
  else
    row--;
  cout << row + pos_time[pos] + rows_num * 6;
  return 0;
}
