def solution(board, h, w):
n = len(board)
count = 0
targetColor = board[h][w]
# 우 하 상 좌 방향
dh = [0, 1, -1, 0]
dw = [1, 0, 0, -1]
for i in range(0, 4):
h_check = h + dh[i]
w_check = w + dw[i]
# 범위검사
if((h_check < 0 or h_check >= n)):
continue
if(w_check < 0 or w_check >= n):
continue
# 색상비교
if(targetColor == board[h_check][w_check]):
count += 1
return count