#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = 8;
  if (s[0] == 'a' || s[0] == 'h') n -= 3;
  if (s[1] == '1' || s[1] == '8') n -= 3;
  if (n < 3) n = 3;
  cout << n;
  return 0;
}
