시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 344 103 80 37.037%

문제

R개의 행과 C개의 열로 이루어진 테이블이 입력으로 들어오게 됩니다. 이 테이블의 원소는 알파벳 소문자로 주어집니다.

각 테이블의 열을 위에서 아래로 읽어서 하나의 문자열을 만들 수 있습니다. 예제 입력에서

dobarz
adatak

이 주어지는 경우 "da", "od", "ba", "at", "ra", "zk"와 같이 6개의 문자열들이 만들어지게 됩니다.

만약 가장 위의 행을 지워도 테이블의 열을 읽어서 문자열이 중복되지 않는다면, 가장 위의 행을 지워주고, count의 개수를 1 증가시키고, 이 과정을 반복합니다. 만약 동일한 문자열이 발견되는 경우, 반복을 멈추고 count의 개수를 출력 후 프로그램을 종료하면 됩니다. (가장 처음에 주어지는 테이블에는 열을 읽어서 문자열을 만들 때, 동일한 문자열이 존재하지 않음이 보장됩니다.)

테이블이 주어질 경우 count의 값을 구해주시면 됩니다.

입력

첫 번째 줄에는 테이블의 행의 개수와 열의 개수인 R과 C가 주어집니다. (2 ≤ R, C ≤ 1000)

이후 R줄에 걸쳐서 C개의 알파벳 소문자가 주어집니다. (가장 처음에 주어지는 테이블에는 열을 읽어서 문자열을 만들 때, 동일한 문자열이 존재하지 않음이 보장됩니다.)

출력

위의 설명과 같이 count의 값을 출력하시면 됩니다.

예제 입력 1

2 6
dobarz
adatak

예제 출력 1

0
W3sicHJvYmxlbV9pZCI6IjI4NjYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJiMzhcdWM3OTBcdWM1ZjQgXHVjNzk4XHViNzdjXHViMGI0XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5SXHVhYzFjXHVjNzU4IFx1ZDU4OVx1YWNmYyBDXHVhYzFjXHVjNzU4IFx1YzVmNFx1Yjg1YyBcdWM3NzRcdWI4ZThcdWM1YjRcdWM5YzQgXHVkMTRjXHVjNzc0XHViZTE0XHVjNzc0IFx1Yzc4NVx1YjgyNVx1YzczY1x1Yjg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