You are planning a trip for the members of a club. However, some of the members dislike other members. Therefore, you decide to choose a subset of members such that:
Inside , noone dislikes anyone.
There is no such that and such that fulfils the first property. In other words, must be maximal.
Given the information about who dislikes who, can you count the number of such subsets?
Input consists of several cases, each one with
followed by
lines with
characters each. For
,
the
-th
character of the
-th
line is ‘L’ or ‘D’ depending on whether
likes or
dislikes .
The diagonal has only dots. Assume
.
For every case, print the number of maximal placid subsets.
Input
2 .D L. 5 .LDDL D.LDL DL.LL LDD.D LLLL. 6 .LLLLL L.LLLL LL.LLL DLL.LL LLDL.L LLLDD.
Output
2 3 4