#include <bits/stdc++.h>
const long long INF = 1LL << 61;
const int inf = 2e9;
bool debug;
using namespace std;
void solve();
int main() {
  debug = 0;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
const int N = 200005;
string s;
long long n, ans;
char c;
void solve() {
  cin >> s;
  for (int i = 0; i < (int)s.size() - 1; i++) n = 10 * n + (s[i] - '0');
  c = s[(int)s.size() - 1];
  long long bef = (n - 1) / 4;
  if (n % 2 == 0) ans += 7;
  ans += bef * 16;
  if (c == 'f') ans += 1;
  if (c == 'e') ans += 2;
  if (c == 'd') ans += 3;
  if (c == 'a') ans += 4;
  if (c == 'b') ans += 5;
  if (c == 'c') ans += 6;
  cout << ans << endl;
}
