package main

import (
	"fmt"
)

func main() {
	var W, H int
	fmt.Scan(&W, &H)
	s := ""
	m := [][]int{}
	for h := 0; h < H; h++ {
		fmt.Scan(&s)
		for w := 0; w < W; w++ {
			tmp := s[w : w+1]
			if tmp == "." {
				m[w][h] = 1
				continue
			}
		}
	}

	odd := 0
	even := 0
	for h := 0; h < H; h++ {
		for w := 0; w < W; w++ {
			location := m[h][w]
			if location == 0 {
				continue
			}
			road := 0
			if w-1 >= 0 && h-1 >= 0 {
				if m[h-1][w-1] == 1 {
					road++
				}
			}
			if w >= 0 && h-1 >= 0 {
				if m[h][w] == 1 {
					road++
				}
			}
			if w+1 < W && h >= 0 {
				if m[h][w+1] == 1 {
					road++
				}
			}
			if w+1 < W && h+1 < H {
				if m[h+1][w+1] == 1 {
					road++
				}
			}
			if road > 1 {
				if road%2 == 0 {
					even++
				} else {
					odd++
				}
			}
		}
	}
	res := even
	if odd > 2 {
		res += 2
	}

	fmt.Println(res)

}
