#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5 + 1, MODM = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  int a = s[0] - 'a';
  int b = s[1] - '1';
  int ans = 0;
  for (int i = -1; i <= 1; i++)
    for (int j = -1; j <= 1; ++j)
      ans += (a + i < 8 && a + i >= 0 && b + j < 8 && b + j >= 0);
  cout << ans - 1;
  return 0;
}
