#include <bits/stdc++.h>
using namespace std;
int solve(char ch) {
  if (ch == 'a') return 4;
  if (ch == 'b') return 5;
  if (ch == 'c') return 6;
  if (ch == 'd') return 3;
  if (ch == 'e') return 2;
  if (ch == 'f') return 1;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  char ch = s[n - 1];
  string st = s.substr(0, n - 1);
  stringstream ss;
  ss << st;
  long long int x;
  ss >> x;
  long long int ind, y;
  y = x - 1;
  if (x % 2 == 0) {
    long long int i = (x + 2) / 4;
    ind = 2 * i;
    if (x % 4 == 0) y = x - 2 - 1;
  } else {
    long long int i = (x + 3) / 4;
    ind = 2 * i - 1;
    if ((x - 3) % 4 == 0) y = x - 2 - 1;
  }
  long long int ans = 6 * (ind - 1) + y;
  ans += solve(ch);
  cout << ans;
  return 0;
}
