#include <bits/stdc++.h>
using namespace std;
int offset[6] = {4, 5, 6, 3, 2, 1};
int main() {
  long long r;
  string str;
  cin >> str;
  char x = str[str.size() - 1];
  str.pop_back();
  stringstream ss;
  ss << str;
  ss >> r;
  r--;
  long long _round = r / 4;
  bool isOdd = r & 1;
  long long ans = 0;
  ans += 16LL * _round;
  if (isOdd) ans += 7;
  ans += offset[x - 'a'];
  cout << ans << endl;
  return 0;
}
