#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string second;
  cin >> second;
  if (second == "a1" || second == "a8" || second == "h1" || second == "h8")
    cout << 3 << '\n';
  else if (second[1] - '0' == 1 || second[1] - '0' == 8 || second[0] == 'a' ||
           second[0] == 'h')
    cout << 5 << '\n';
  else
    cout << 8 << '\n';
  return 0;
}
