#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  int cases, caseno = 0, n, i, j, k, cnt, sum;
  string s;
  cin >> s;
  sum = 8;
  if (s[0] == 'a' || s[0] == 'h') sum -= 3;
  if (s[1] == '1' || s[1] == '8') sum -= 3;
  if (s[0] == 'a' && s[1] == '1' || s[0] == 'a' && s[1] == '8') sum++;
  if (s[0] == 'h' && s[1] == '1' || s[0] == 'h' && s[1] == '8') sum++;
  cout << sum << '\n';
  return 0;
}
