#include <bits/stdc++.h>
using namespace std;
int main() {
  char cd[5];
  scanf("%s", cd);
  if ((cd[0] == 'a' || cd[0] == 'h') && (cd[1] == '1' || cd[1] == '8'))
    cout << 3;
  else if (cd[0] == 'a' || cd[0] == 'h')
    cout << 5;
  else if (cd[1] == '1' || cd[1] == '8') {
    cout << 5;
  } else
    cout << 8;
}
