#abc358c. C - Popcorn

C - Popcorn

Score : 300300 points

问题陈述

在AtCoder Land,有NN个爆米花摊位,编号从11NN。它们有MM种不同的爆米花口味,标记为1,2,,M1, 2, \dots, M,但并不是每个摊位都出售所有口味的爆米花。

高桥获得了关于每个摊位出售哪些口味爆米花的信息。这些信息由NN个长度为MM的字符串S1,S2,,SNS_1, S_2, \dots, S_N表示。如果SiS_i的第jj个字符是o,这意味着摊位ii出售第jj种口味的爆米花。如果是x,则意味着摊位ii不出售第jj种口味的爆米花。每个摊位至少出售一种口味的爆米花,每种口味的爆米花至少在一个摊位出售。

高桥想要尝试所有口味的爆米花,但不想走太多路。确定高桥需要访问的最少摊位数量,以购买所有口味的爆米花。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

In AtCoder Land, there are NN popcorn stands numbered 11 to NN. They have MM different flavors of popcorn, labeled 1,2,,M1, 2, \dots, M, but not every stand sells all flavors of popcorn.

Takahashi has obtained information about which flavors of popcorn are sold at each stand. This information is represented by NN strings S1,S2,,SNS_1, S_2, \dots, S_N of length MM. If the jj-th character of SiS_i is o, it means that stand ii sells flavor jj of popcorn. If it is x, it means that stand ii does not sell flavor jj. Each stand sells at least one flavor of popcorn, and each flavor of popcorn is sold at least at one stand.

Takahashi wants to try all the flavors of popcorn but does not want to move around too much. Determine the minimum number of stands Takahashi needs to visit to buy all the flavors of popcorn.

Constraints

  • NN and MM are integers.
  • 1N,M101 \leq N, M \leq 10
  • Each SiS_i is a string of length MM consisting of o and x.
  • For every ii (1iN)(1 \leq i \leq N), there is at least one o in SiS_i.
  • For every jj (1jM)(1 \leq j \leq M), there is at least one ii such that the jj-th character of SiS_i is o.

Input

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

NN MM

S1S_1

S2S_2

\vdots

SNS_N

Output

Print the minimum number of stands Takahashi needs to visit to buy all the flavors of popcorn.

Sample Input 1

3 5
oooxx
xooox
xxooo

Sample Output 1

2

By visiting the 1st and 3rd stands, you can buy all the flavors of popcorn. It is impossible to buy all the flavors from a single stand, so the answer is 22.

Sample Input 2

3 2
oo
ox
xo

Sample Output 2

1

Sample Input 3

8 6
xxoxxo
xxoxxx
xoxxxx
xxxoxx
xxoooo
xxxxox
xoxxox
oxoxxo

Sample Output 3

3