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