#include <bits/stdc++.h>
int main() {
  int m = 8, n = 3, q = 5;
  char ch[3];
  scanf("%s", ch);
  if (ch[0] == 'a' && ch[1] == '8') {
    printf("%d\n", n);
    return 0;
  } else if (ch[0] == 'a' && ch[1] == '1') {
    printf("%d\n", n);
    return 0;
  } else if (ch[0] == 'h' && ch[1] == '1') {
    printf("%d\n", n);
    return 0;
  } else if (ch[0] == 'h' && ch[1] == '8') {
    printf("%d\n", n);
    return 0;
  } else if (ch[0] == 'a' && (ch[1] >= 49 && ch[1] <= 57)) {
    printf("%d\n", q);
    return 0;
  } else if (ch[0] == 'h' && (ch[1] >= 49 && ch[1] <= 57)) {
    printf("%d\n", q);
    return 0;
  } else if ((ch[0] >= 97 && ch[0] <= 105) && (ch[1] == '8')) {
    printf("%d\n", q);
    return 0;
  } else if ((ch[0] >= 97 && ch[0] <= 105) && (ch[1] == '1')) {
    printf("%d\n", q);
    return 0;
  } else
    printf("%d\n", m);
  return 0;
}
