#K50397. Counting Apple Trees
Counting Apple Trees
Counting Apple Trees
You are given an M x N grid representing an orchard. Each cell in the grid contains a single character denoting the type of tree or ground condition. The character 'A' represents an apple tree. Your task is to count the total number of apple trees in the grid.
For example, given a grid:
$$\begin{array}{ccc} A & O & A \\ D & A & O \\ O & D & A \end{array} $$The answer is 4, as there are four cells with 'A'.
Input is read from stdin and output should be written to stdout.
inputFormat
The first line contains two integers M and N separated by a space, indicating the number of rows and columns of the grid respectively. The following M lines each contain N space-separated characters representing the grid cells.
Example:
3 3 A O A D A O O D A
outputFormat
Output a single integer — the number of cells that contain the apple tree 'A'.
Example:
4## sample
3 3
A O A
D A O
O D A
4