output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      H
      W
attempt: # H,W = 3,3
  # s = [".#.", "..#", "#.."]
  
  from collections import deque
  
  H, W = map(int, input().split())
  s = [input() for _ in range(H)]
  
  ans = 0
  kaburi = 0
  for i in range(H):
      for j in range(W):
          if s[i][j] == ".":
              continue
          stk = deque([(i, j)])  # stktack
          visited = set([(i, j)])
          while stk:  # なくなるまで
              y, x = stk.popleft()
  
              for dy, dx in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                  if 0 <= y + dy < H and 0 <= x + dx < W:
                      if (s[y][x] == "." and s[y + dy][x + dx] == "#") or (
                          s[y][x] == "#" and s[y + dy][x + dx] == "."
                      ):
                          if (y + dy, x + dx) in visited:
                              continue
                          stk.append([y + dy, x + dx])
                          visited.add((y + dy, x + dx))
                          # print(i,j, y+dy,x+dx, ans)
                          if s[y + dy][x + dx] == "#":
                              kaburi += 1
                          ans += 1
  print(ans - kaburi)
  
problem_description: Statement
  
  It has been decided that a programming contest sponsored by company A will be
  held, so we will post the notice on a bulletin board.
  
  The bulletin board is in the form of a grid with N rows and N columns, and the
  notice will occupy a rectangular region with H rows and W columns.
  
  How many ways are there to choose where to put the notice so that it
  completely covers exactly HW squares?
samples: [{"input": "3\n    2\n    3", "output": "2\n    \n\nThere are two ways to put the notice, as follows:\n\n    \n    \n    ###   ...\n    ###   ###\n    ...   ###\n    \n\nHere, `#` represents a square covered by the notice, and `.` represents a\nsquare not covered.\n\n* * *"}, {"input": "100\n    1\n    1", "output": "10000\n    \n\n* * *"}, {"input": "5\n    4\n    2", "output": "8"}]