#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
void solve() {
  char a, b;
  cin >> a >> b;
  long long count = 0;
  if (a == 'a' || a == 'h') count++;
  if (b == '1' || b == '8') count++;
  if (count == 1)
    cout << "5";
  else if (count == 2)
    cout << "3";
  else if (count == 0)
    cout << "8";
}
int32_t main() { solve(); }
