#include <bits/stdc++.h>
using namespace std;
string s;
void init() { cin >> s; }
void process() {
  char p = s.back();
  s.pop_back();
  long long n;
  stringstream ss;
  ss << s;
  ss >> n;
  long long res = 0;
  switch (p) {
    case 'f':
      res = 1;
      break;
    case 'e':
      res = 2;
      break;
    case 'd':
      res = 3;
      break;
    case 'a':
      res = 4;
      break;
    case 'b':
      res = 5;
      break;
    case 'c':
      res = 6;
      break;
  }
  if (n % 4 == 1 || n % 4 == 2) {
    res += (n / 4) * 6 * 2 + (n - 1);
    if (n % 4 == 2) res += 6;
  } else {
    res += ((n - 1) / 4) * 6 * 2 + (n - 3);
    if (n % 4 == 0) res += 6;
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  init();
  process();
}
