#include <bits/stdc++.h>
using namespace std;
long long int M = 1e9 + 7;
int main() {
  unsigned long long int ans, n, m, rowCov;
  string st;
  char ch;
  unsigned long long int arr[6] = {4, 5, 6, 3, 2, 1};
  cin >> st;
  ch = st[st.size() - 1];
  st = st.substr(0, st.size() - 1);
  string::size_type sz = 0;
  n = stoull(st, &sz, 0);
  m = (n & 1) ? 0 : 1;
  rowCov = ((n - 1) / 4) * 16;
  ans = rowCov + 7 * m + arr[ch - 'a'];
  std::cout << ans << endl;
  return 0;
}
