#include <bits/stdc++.h>
using namespace std;
void file() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
string s;
long long n, num, k1, ans, l, r, mid, nn;
char k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  getline(cin, s);
  k = s[s.length() - 1];
  if (k == 'f')
    num = 1;
  else if (k == 'e')
    num = 2;
  else if (k == 'd')
    num = 3;
  else if (k == 'c')
    num = 6;
  else if (k == 'b')
    num = 5;
  else if (k == 'a')
    num = 4;
  for (int i = 0; i < s.length() - 1; ++i) {
    n *= 10;
    n += (s[i] - '0');
  }
  nn = n;
  if (n % 2 == 1) {
    n /= 4;
    n *= 2;
    ans += n;
    ans -= (n / 2);
    ans += (n / 2) * 3;
    ans += n * 6;
    ans += num;
  } else {
    n /= 4;
    if (nn % 4 == 0) n--;
    n *= 2;
    n++;
    ans += n;
    ans -= (n / 2);
    ans += (n / 2) * 3;
    ans += n * 6;
    ans += num;
  }
  cout << ans;
}
