The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.

Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).

<image> King moves from the position e4

Input

The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.

Output

Print the only integer x — the number of moves permitted for the king.

Example

Input

e4


Output

8
# @Date    : 2016-08-22 19:21:32
# @Problem : 


import unittest

from random import randint, shuffle
from sys import maxsize

class StressTest(unittest.TestCase):
	known_values = (
		# A,  expected
		("e4",  8),
	)

	def test_known_cases(self):
		for A, expected in self.known_values:
			self.assertEqual(expected, NaiveSolution().kingMoves(A))

	def test_all_cases(self):	
		while True:
			break


class NaiveSolution:
	def kingMoves(self, A):
		cols = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7}
		rows = {'8':0, '7':1, '6':2, '5':3, '4':4, '3':5, '2':6, '1':7}
		r, c = (rows[A[1]], cols[A[0]])

		count = 0

		# top left diagonal
		if r-1 >= 0 and c-1 >= 0: count += 1

		# top right diagonal
		if r-1 >= 0 and c+1 <= 7: count += 1

		# bottom left diagonal
		if r+1 <= 7 and c-1 >= 0: count += 1

		# bottom right diagonal
		if r+1 <= 7 and c+1 <= 7: count += 1

		# top 
		if r-1 >= 0: count += 1

		# bottom
		if r+1 <= 7: count += 1

		# left
		if c-1 >= 0: count += 1

		# right
		if c+1 <= 7: count += 1


		return count




class BestSolution:
	pass


if __name__ == '__main__':
	#unittest.main()

	ans = NaiveSolution().kingMoves(input().strip())
	print(ans)



