You stumble across a jungle rumored to have ancient treasures in it. Luckily, you have a map of the jungle with the locations of the treasure chests.
Your map contains the following legend:
Symbol | Description |
---|---|
. |
Terrain you may walk through |
X |
A tree obstructing your path |
S |
Your starting position |
C |
A treasure chest |
From any given position, you may travel to an adjacent square as long as it is not covered by a tree.
Given the contents of the map with rows and columns, determine the maximum amount of treasure chests you are able to loot.
Constraints
Input Specification
The first line of input contains space-separated integers, and .
The next lines of input each contain characters, representing the contents of the map.
It is guaranteed that S
will appear exactly once and all other characters will be present on the legend.
Output Specification
Output a single integer, the total number of treasure chests that are reachable from your starting position.
Sample Input
3 7
S..C.X.
XX..X.C
C...X..
Sample Output
2
Comments