#include <bits/stdc++.h>
using namespace std;
string a;
int main() {
  cin >> a;
  if (a == "a8" || a == "h8" || a == "h1" || a == "a1")
    printf("3");
  else if (a[0] == 'a' || a[0] == 'h' || a[1] == '1' || a[1] == '8')
    printf("5");
  else
    printf("8");
  return 0;
}
