#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string s;
  cin >> s;
  long long int a[6] = {4, 5, 6, 3, 2, 1};
  char c = char(s[s.length() - 1]);
  long long int n = 0, t = 10;
  for (int i = 0; i < s.length() - 1; i++) {
    n = n * t + int(s[i] - '0');
  }
  long long int temp = (n - 1) / 4;
  if (n <= 4) {
    if (n % 2 == 0) {
      cout << a[c - 'a'] + 7 << endl;
      return 0;
    } else {
      cout << a[c - 'a'] << endl;
      return 0;
    }
  }
  long long int ans = temp * 16;
  if (n % 2 == 0) {
    ans = ans + a[c - 'a'] + 7;
    cout << ans << endl;
  } else {
    ans = ans + a[c - 'a'];
    cout << ans << endl;
  }
}
