The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. 

In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 × 2 square, such that from the four letters of this square you can make word "face". 

You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.


-----Input-----

The first line contains two space-separated integers, n and m (1 ≤ n, m ≤ 50) — the height and the width of the image, respectively.

Next n lines define the image. Each line contains m lowercase Latin letters.


-----Output-----

In the single line print the number of faces on the image.


-----Examples-----
Input
4 4
xxxx
xfax
xcex
xxxx

Output
1

Input
4 2
xx
cf
ae
xx

Output
1

Input
2 3
fac
cef

Output
2

Input
1 4
face

Output
0



-----Note-----

In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:  [Image] 

In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.

In the third sample two faces are shown:  $\text{fac}$ 

In the fourth sample the image has no faces on it.

Difficulty: interview

Starter code:

Solutions:
n, m = list(map(int, input().split()))

field = []
for i in range(n):
    field.append(input())

ans = 0
for i in range(n - 1):
    for j in range(m - 1):
        t = set()
        t.add(field[i][j])
        t.add(field[i + 1][j + 1])
        t.add(field[i + 1][j])
        t.add(field[i][j + 1])

        if t == set('face'):
            ans += 1
print(ans)


"""
Codeforces Looksery Cup 2015 Problem A

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    n,m = read()
    s = []
    for i in range(n): s.append(read(0))

    ans = 0
    for i in range(n-1):
        for j in range(m-1):
            if {s[i][j], s[i][j+1], s[i+1][j], s[i+1][j+1]} == set("face"):
                ans += 1
    return ans



#################################################### HELPERS



def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

n, m = list(map(int, input().split()))
ans = 0
A = [input() for i in range(n)]
for i in range(n - 1):
    for j in range(m - 1):
        if sorted(A[i][j] + A[i][j + 1] + A[i + 1][j] + A[i + 1][j + 1]) == sorted("face"):
            ans += 1
print(ans)



n, m = (int(x) for x in input().split())
a = []
for i in range(n):
	a.append(input())
ok = set('face')
ans = 0
for i in range(n - 1):
	for j in range(m - 1):
		test = set([a[i][j], a[i + 1][j], a[i][j + 1], a[i + 1][j + 1]])
		if test == ok:
			ans += 1
print(ans)


n, m = map(int, input().split())
a = [input().replace('', ' ').split() for i in range(n)]
res = 0
for i in range(n - 1):
    for j in range(m - 1):
        s = a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]
        if sorted(s) ==  ['a', 'c', 'e', 'f']: res += 1
print(res)

n, m = list(map(int, input().split()))
a = [input().strip() for x in range(n)]
print(sum(set([a[i][j], a[i + 1][j], a[i][j + 1], a[i + 1][j + 1]]) == set('face') for i in range(n - 1) for j in range(m - 1)))


import sys

def main():
    # fin = open("input.txt", "r")
    fin = sys.stdin
    
    n, m = map(int, fin.readline().split())
    A = []
    for i in range(n):
        A.append(fin.readline().rstrip())

    cnt = 0
    for i in range(n - 1):
        for j in range(m - 1):
            S = {A[i][j], A[i][j + 1], A[i + 1][j], A[i + 1][j + 1]}
            if ("f" in S) and ("a" in S) and ("c" in S) and ("e" in S):
                cnt += 1

    print(cnt)

    fin.close()

main()

n, m = [int(i) for i in input().split()]
d = [input() for i in range(n)]

result = 0
for i in range(n - 1):
    for j in range(m - 1):
        if sorted(d[i][j] + d[i + 1][j] + d[i][j + 1] + d[i + 1][j + 1]) == sorted(list("face")):
            result += 1

print(result)


#!/usr/bin/env python3.4

n, m = list(map(int, input().split()))
board = []
for i in range(n):
    board.append(input())
ok_set = set(['f', 'a', 'c', 'e'])
ans = 0
for i in range(n - 1):
    for j in range(m - 1):
        cur_set = set([board[i][j], board[i][j + 1], board[i + 1][j], board[i + 1][j + 1]])
        if cur_set == ok_set:
            ans += 1
print(ans)


import sys



input       = []
input_index = 0

def next(type, number = None):
	def next():
		nonlocal input, input_index
		
		
		while input_index == len(input):
			if sys.stdin:
				input       = sys.stdin.readline().split()
				input_index = 0
			else:
				raise Exception()
				
				
		input_index += 1
		
		return input[input_index - 1]
		
		
	if number is None:
		result = type(next())
	else:
		result = [type(next()) for _ in range(number)]
		
	return result
	
	
	
n, m = next(int, 2)
iis = [next(str) for _ in range(n)]


count = 0

for i in range(n - 1):
	for j in range(m - 1):
		s = {iis[i][j], iis[i+1][j], iis[i][j+1], iis[i+1][j+1]}
		
		if "f" in s and "a" in s and "c" in s and "e" in s:
			count += 1
			
			
print(count)


n, m = [int(i) for i in input().split()]
s = []
o = 0
for t in range(n):
    s.append(input())
for i in range(n-1):
    for j in range(m-1):
        a = s[i][j]+s[i][j+1]+s[i+1][j]+s[i+1][j+1]
        if "f" in a and "c" in a and "e" in a and "a" in a:
            o+=1
print(o)


n,m = [int(c) for c in input().split()]

lines = []
for i in range(n):
    lines.append(input())

f = 0
for i in range(n-1):
    for j in range(m-1):
        s = set()
        s.add(lines[i][j])
        s.add(lines[i+1][j])
        s.add(lines[i][j+1])
        s.add(lines[i+1][j+1])
        if 'f' in s and 'a' in s and 'c' in s and 'e' in s:
            f +=1

print(f)


n, m = list(map(int, input().split()))
board = [input() for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(m-1):
        s = [board[i][j], board[i+1][j], board[i][j+1], board[i+1][j+1]]
        if 'f' in s and 'a' in s and 'c' in s and 'e' in s:
            ans += 1
print(ans)


n, m = map(int, input().split())
t = []
cnt = 0
for i in range(n):
    t.append(input())
for i in range(n - 1):
    for j in range(m - 1):
        s = ''
        s += t[i][j]
        s += t[i + 1][j]
        s += t[i][j + 1]
        s += t[i + 1][j + 1]
        s = ''.join(sorted(list(s)))
        if s == 'acef':
            cnt += 1
print(cnt)

n, m = [int(x) for x in input().split()]
a = []
for i in range(n):
    a.append(input())
#print(a)
res = 0
z = ["face", "faec", "feac", "feca", "fcae", "fcea", "eafc", "eacf", "ecaf", "ecfa", "efac", "efca", "acfe", "acef", "aecf", "aefc", "afce", "afec", "cafe", "caef", "ceaf", "cefa", "cfea", "cfae"]
for i in range(1, n):
    for j in range(1, m):
        if a[i][j]+a[i][j-1]+a[i-1][j]+a[i-1][j-1] in z:
            res += 1
print(res)

data = []
face = set({'f', 'a', 'c', 'e'})


def check(data, i, j):
    s = set()
    s.add(data[i][j])
    s.add(data[i + 1][j])
    s.add(data[i + 1][j + 1])
    s.add(data[i][j + 1])

    if len(s & face) == 4:
        return True

    return False


def __starting_point():
    n, m = map(int, input().split())

    for i in range(n):
        data.append(input())

    total = 0
    for i in range(n - 1):
        for j in range(m - 1):
            if check(data, i, j):
                total += 1

    print(total)
__starting_point()

__author__ = 'Данила'
n, m  = map(int, input().split())
mat = [['' for i in range(m)] for j in range(n)]

for i in range(n):
    s = input().rstrip()
    for j in range(len(s)):
        mat[i][j] = s[j]
cnt = 0
for i in range(n - 1):
    for j in range(m - 1):
        mn = set()
        mn.add(mat[i][j])
        mn.add(mat[i + 1][j])
        mn.add(mat[i][j + 1])
        mn.add(mat[i + 1][j + 1])
        if 'f' in mn and 'a' in mn and 'c' in mn and 'e' in mn:
            cnt += 1

print(cnt)

a,b=input().split()
n=int(a)
m=int(b)
t=["" for j in range(n)]
for i in range(n):
	t[i]=input()
v=0

def test(a,b,c,d):
	g=[0 for i in range(200)]
	g[ord(a)]+=1
	g[ord(b)]+=1
	g[ord(c)]+=1
	g[ord(d)]+=1
	return (g[ord('f')]*g[ord('a')]*g[ord('c')]*g[ord('e')]==1)

for i in range(n-1):
	for j in range(m-1):
		if test(t[i][j],t[i+1][j],t[i][j+1],t[i+1][j+1]):v+=1
print(v)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

face = set('face')
n,m = list(map(int,input().split()))
faces = []
for i in range(n):
    faces.append(list(input()))

count = 0
for i in range(n):
    for j in range(m):
        dxdy = [(0,0),(0,1),(1,1),(1,0)]
        f = []
        for dx,dy in dxdy:
            if 0 <= dy + i < n and 0 <= dx + j < m:
                f.append(faces[i + dy][j + dx])
        if face == set(f):
            count += 1
print(count)


R = lambda:list(map(int,input().split()))
n,m = R()
rs = 0
a = []
for i in range(n):
    a.append(input())
    
for i in range(n-1):
    for j in range(m-1):
        c = []
        c.append(a[i][j])
        c.append(a[i+1][j])
        c.append(a[i][j+1])
        c.append(a[i+1][j+1])
        u = set(c)
        if len(u) == 4:
            if 'f' in u:
                if 'a' in u:
                    if 'c' in u:
                        if 'e' in u:
                            rs += 1     
print(rs)

N,M=list(map(int,input().split()))
Seq=[list(input())for I in range(N)]
Ans=0
for I in range(N-1):
    for J in range(M-1):
        Det=['f','a','c','e']
        Used=[]
        if Seq[I][J]in Det:
            Used.append(Seq[I][J])
            if Seq[I+1][J]in Det and not Seq[I+1][J]in Used:
                Used.append(Seq[I+1][J])
                if Seq[I][J+1]in Det and not Seq[I][J+1]in Used:
                    Used.append(Seq[I][J+1])
                    if Seq[I+1][J+1]in Det and not Seq[I+1][J+1]in Used:
                        '''
                        Seq[I][J]='#'
                        Seq[I+1][J]='#'
                        Seq[I+1][J+1]='#'
                        Seq[I][J+1]='#'
                        '''
                        Ans+=1
print(Ans)


n, m = list(map(int, input().split()))
grid = [list(input()) for i in range(n)]
cnt = 0
for r in range(n-1):
    for c in range(m-1):
        face = ['f', 'a', 'c', 'e']
        if grid[r][c] in face:
            face.remove(grid[r][c])
            if grid[r+1][c] in face:
                face.remove(grid[r+1][c])
                if grid[r][c+1] in face:
                    face.remove(grid[r][c+1])
                    if grid[r+1][c+1] in face:
                        face.remove(grid[r+1][c+1])
                        cnt += 1
print(cnt)


n,m = map(int,input().split())
lines = [input() for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(m-1):
        a = lines[i][j]+lines[i+1][j]+lines[i][j+1]+lines[i+1][j+1]
        if 'f' in a and 'a' in a and 'c' in a and 'e' in a:
            ans+=1
print(ans)

n, m = list(map(int,input().split()))
icon = [input() for i in range(n)]
faces = 0
for i in range(n-1):
    for j in range(m-1):
        temp = 0
        temp2 = 0
        temp3 = 0
        temp4 = 0
        if icon[i][j] == "f":
            temp += 1
        elif icon[i][j] == "a":
            temp2 += 1
        elif icon[i][j] == "c":
            temp3 += 1
        elif icon[i][j] == "e":
            temp4 += 1
        if icon[i+1][j] == "f":
            temp += 1
        elif icon[i+1][j] == "a":
            temp2 += 1
        elif icon[i+1][j] == "c":
            temp3 += 1
        elif icon[i+1][j] == "e":
            temp4 += 1
        if icon[i][j+1] == "f":
            temp += 1
        elif icon[i][j+1] == "a":
            temp2 += 1
        elif icon[i][j+1] == "c":
            temp3 += 1
        elif icon[i][j+1] == "e":
            temp4 += 1
        if icon[i+1][j+1] == "f":
            temp += 1
        elif icon[i+1][j+1] == "a":
            temp2 += 1
        elif icon[i+1][j+1] == "c":
            temp3 += 1
        elif icon[i+1][j+1] == "e":
            temp4 += 1
        if temp == 1 and temp2 == 1 and temp3 == 1 and temp4 == 1:
            faces += 1
print(faces)


def calc(img):
    nr = len(img)
    nc = len(img[0])
    ret = 0
    for i in range(nr-1):
        for j in range(nc-1):
            tset = set()
            tset.add(img[i][j])
            tset.add(img[i][j+1])
            tset.add(img[i+1][j])
            tset.add(img[i+1][j+1])
            if 'f' in tset and 'a' in tset and 'c' in tset and 'e' in tset:
                ret += 1
    return ret  

def main():
    items = input().split()
    nr = int(items[0])
    nc = int(items[1])
    img = []
    for _ in range(nr):
        img.append(input())
    print(calc(img))

    
def __starting_point():
    main()

__starting_point()