# H * W, [i - 1][j - 1] # or .
# size forAll false -> forAll true
H, W = gets.split.map(&:to_i)
B = Array.new(H + 2) { Array.new(W + 2, nil) }
H.times {|i| B[i + 1] = [nil, *gets.chomp.chars, nil] }

$ans = 0

def tour(x, y, flags, n) # : Int
  flags[x][y] = true
  # puts " " * n + "from (#{x}, #{y})"
  [[0, -1], [-1, 0], [0, 1], [1, 0]].each {|dx, dy|
    next if B[x][y] == B[x + dx][y + dy] || B[x + dx][y + dy] == nil
    if !flags[x + dx][y + dy] && B[x][y] != B[x + dx][y + dy]
      $ans += 1 if B[x + dx][y + dy] == '.'
      # puts " " * n + "to (#{x + dx}, #{y + dy})"
      tour(x + dx, y + dy, flags, n + 1)

    end
  }
  # puts " " * n + "end"
  return
end

H.times{|i|
  W.times{|j|
    flags = Array.new(H + 2) { Array.new(W + 2, false) }
    flags[i + 1][j + 1] = true
    tour(i + 1, j + 1, flags, 0) if B[i + 1][j + 1] == '#'
  }
}

p $ans