atcoder#ABC282B. [ABC282B] Let's Get a Perfect Score

[ABC282B] Let's Get a Perfect Score

Score : 200200 points

Problem Statement

NN participants, numbered 11 to NN, will participate in a contest with MM problems, numbered 11 to MM.

For an integer ii between 11 and NN and an integer jj between 11 and MM, participant ii can solve problem jj if the jj-th character of SiS_i is o, and cannot solve it if that character is x.

The participants must be in pairs. Print the number of ways to form a pair of participants who can collectively solve all the MM problems.

More formally, print the number of pairs (x,y)(x,y) of integers satisfying 1x<yN1\leq x < y\leq N such that for any integer jj between 11 and MM, at least one of participant xx and participant yy can solve problem jj.

Constraints

  • NN is an integer between 22 and 3030, inclusive.
  • MM is an integer between 11 and 3030, inclusive.
  • SiS_i is a string of length MM consisting of o and x.

Input

The input is given from Standard Input in the following format:

NN MM

S1S_1

S2S_2

\vdots

SNS_N

Output

Print the answer.

5 5
ooooo
oooxx
xxooo
oxoxo
xxxxx
5

The following five pairs satisfy the condition: participants 11 and 22, participants 11 and 33, participants 11 and 44, participants 11 and 55, and participants 22 and 33.

On the other hand, the pair of participants 22 and 44, for instance, does not satisfy the condition because they cannot solve problem 44.

3 2
ox
xo
xx
1
2 4
xxxx
oxox
0