文理学院程序设计在线练习


contains ACM

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 61   Accepted Submission(s): 36
Problem Description

This time is ACM contest, Xenocide don't have to take part in the contest eventually. But coach don't want to let him free, so he is sent to take photos. In order to highlight this contest is an ACM contest more, coach hopes Xenocide to find some photos that contains "ACM" as more as possible. Xenocide is a very lazy man, so he wishes us to help him to count the number of "ACM" in a photo, then he will find the photos that he need.

Input

There are several test cases.
Each case there is a line containing two integers N and M(3<=N,M<=10). Following is N lines. Each line there are M capital letters meaning the information of the photo.

Output

For each case output an integer meaning the number of "ACM"s that the photo contains. The "A" "C" "M" three characters appears in turn that counts as one time. No matter vertical of horizontal is both ok. One character can appear in several "ACM" strings.

Sample Input
3 3
ACM
CMA
MCA
4 3
ACM 
ACM
ACM
ACM
Sample Output
2
4