#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch1, ch2;
  scanf("%c%c", &ch1, &ch2);
  if (ch1 == 'a' && ch2 == '1')
    printf("3\n");
  else if (ch1 == 'a' && ch2 == '8')
    printf("3\n");
  else if (ch1 == 'h' && ch2 == '1')
    printf("3\n");
  else if (ch1 == 'h' && ch2 == '8')
    printf("3\n");
  else if (ch1 == 'a' || ch1 == 'h' || ch2 == '1' || ch2 == '8')
    printf("5\n");
  else
    printf("8\n");
  return 0;
}
