#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double E = exp(1.0);
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline T Min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T Max(T a, T b) {
  return a > b ? a : b;
}
int n, m;
int len;
char pos[25];
int getseat() {
  char ch = pos[len - 1];
  switch (ch) {
    case 'f':
      return 1;
      break;
    case 'e':
      return 2;
      break;
    case 'd':
      return 3;
      break;
    case 'a':
      return 4;
      break;
    case 'b':
      return 5;
      break;
    case 'c':
      return 6;
      break;
  }
  return 0;
}
long long getcow() {
  long long ret = 0;
  for (int i = (0); i < (len - 1); ++i) {
    ret += (pos[i] - '0');
    if (i != len - 2) ret *= 10;
  }
  return ret;
}
int main() {
  while (~scanf("%s", pos)) {
    len = strlen(pos);
    long long cow = getcow();
    long long seat = getseat();
    long long extra = (cow - 1) / 4;
    if (extra < 0)
      extra = 0;
    else
      extra *= 2;
    cow = ((cow - 1) / 4) * 2 + (cow % 2 == 0);
    printf("%I64d\n", cow * 7 + extra + seat);
  }
  return 0;
}
