#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int MAX = 1e5 + 7;
using namespace std;
string st = "fedabc";
void solve(unsigned long long n, char c) {
  n--;
  unsigned long long res = 16LL * (n / 4LL);
  if (n % 2) res += 7;
  res += st.find(c) + 1;
  cout << res;
}
void mysolve(unsigned long long n, char c) {
  unsigned long long l = 0, r = n / 2;
  unsigned long long res = 0;
  while (l <= r) {
    unsigned long long mid = (l + r) / 2;
    if ((1 + (mid + (mid * 3LL))) <= n) {
      res = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  unsigned long long currF = (1 + (res + (res * 3)));
  unsigned long long served = 2LL * res;
  unsigned long long sec = 6;
  if ((currF == n) || (currF + 2 == n)) {
    sec += ((served - 1) * 6) + (currF - 1);
  } else if (currF + 1 == n || currF + 3 == n) {
    sec += (served * 6) + (currF);
  } else if (currF + 4 == n || currF + 6 == n) {
    sec += ((served + 1) * 6) + (currF + 1);
  }
  for (auto i : st) {
    sec++;
    if (i == c) break;
  }
  cout << sec;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  unsigned long long n = stoll(s.substr(0, s.size() - 1));
  char seat = s[s.size() - 1];
  solve(n, seat);
}
