# f513. 舉旗遊戲 (Flag)
## 題目連結: [f513](https://zerojudge.tw/ShowProblem?problemid=f513)
## 解題想法
* 把資料變成一個二維陣列
* 把這個二維陣列的邊邊都加上0,所以在判斷的時候就不會有超出範圍的問題
* 判斷四面八方有沒有一樣的,如果都沒有`count`就+1
## 程式碼
```py=
a,b = map(int,input().split())
# 創建四邊都是0的二維陣列
table = [[0 for i in range(b+2)]]
for i in range(1,a+1):
table.append([int(j) for j in input().split()])
table[i].insert(0,0)
table[i].append(0)
table.append([0 for i in range(b+2)])
count = 0
for i in range(1,a+1):
for j in range(1,b+1):
now = table[i][j]
ok = False
if now == table[i-1][j-1]:
ok = True
elif now == table[i-1][j]:
ok = True
elif now == table[i-1][j+1]:
ok = True
elif now == table[i][j-1]:
ok = True
elif now == table[i][j+1]:
ok = True
elif now == table[i+1][j-1]:
ok = True
elif now == table[i+1][j]:
ok = True
elif now == table[i+1][j+1]:
ok = True
if ok == False:
count += 1
print(count)
```