h,w = gets.chomp.split.map(&:to_i)
s,cou = [],0
h.times do
  s << gets.chomp.split("").map(&:to_s)
end
for aa in 0...w;for bb in 0...h
  if s[aa][bb] == "#"
    begin
    if s[aa+1][bb] == "."
      cou += 1
    end
    rescue;end
    begin
    if s[aa-1][bb] == "." && (aa-1) >= 0
      cou += 1
    end
    rescue;end
    begin
    if s[aa][bb+1] == "."
      cou += 1
    end
    rescue;end
    begin
    if s[aa][bb-1] == "."&&(bb-1) >= 0
      cou += 1
    end
    rescue;end
    begin
    if s[aa-1][bb-1] == "#";if s[aa-1][bb] == "." || s[aa][bb-1] == "."
      cou += 1 if (aa-1) >= 0 && (bb-1) >= 0
    end;end
    rescue;end
    begin
    if s[aa-1][bb+1] == "#";if s[aa-1][bb] == "." || s[aa][bb+1] == "."
      cou += 1 if (aa-1) >= 0 && (bb-1) >= 0
    end;end
    rescue;end
    begin
    if s[aa+1][bb-1] == "#";if s[aa+1][bb] == "." || s[aa][bb-1] == "."
      cou += 1 if (aa-1) >= 0 && (bb-1) >= 0
    end;end
    rescue;end
    begin
    if s[aa+1][bb+1] == "#";if s[aa+1][bb] == "." || s[aa][bb+1] == "."
      cou += 1 if (aa-1) >= 0 && (bb-1) >= 0
    end;end
    rescue;end
   end
end;end
puts cou
  