시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 330 72 45 21.429%

문제

이모티콘은 채팅과 이메일에서 단어로 표현할 수 없는 감정을 나타내기 위해 종종 쓰인다. 이는 다양한 면에서 장점이 있지만, 많은 사람들은 이모티콘을 매우 짜증난다고 여기며, 없애고 싶어한다.

세종이가 딱 그렇다. 세종이는 이모티콘을 너무 싫어한 나머지, 전세계의 이메일에서 이모티콘을 없애버릴 계획을 세웠다. 당신은 세종이와 계획을 함께 준비하고 있어서, 세종이를 도와줄 특별한 프로그램을 제작하려고 한다.

프로그램은 제거할 이모티콘의 리스트를 먼저 받는다. 각 이모티콘은 공백(whitespace)을 포함하지 않은 문자열이다. 또한 몇몇 텍스트도 함께 받는다. 이때 프로그램이 해야 할 일은 텍스트의 몇몇 글자를 공백으로 바꿔서 원래 존재하던 모든 이모티콘을 없애버리는 것이다. 원래 텍스트의 한 줄에만 걸쳐 나타나며, 사이에 다른 공백이나 문자열이 끼어 있지 않은 이모티콘만을 이모티콘이라고 할 것이다.

세종이의 계획을 최대한 들통나지 않게 하기 위해, 당신은 공백으로 대체할 문자의 개수를 최소한으로 해야 한다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다.

각 테스트 케이스는 여러 줄로 이루어져 있다. 첫 번째 줄은 이모티콘의 개수 N과 텍스트 줄 수 M이 주어지며, 다음 N개의 줄에는 15글자 이하의 비어 있지 않은 문자열인 각 이모티콘이 주어진다. 그 다음 M개의 줄에는 이모티콘을 지울 텍스트들이 주어지며 80글자 이하이다. 1 ≤ N, M ≤ 100 이라 가정해도 좋다.

이모티콘은 영어 대소문자, 숫자, 그리고 특수문자 “!?.,:;-_'#\$%&/=*+(){}[]”(큰따옴표는 포함되지 않음)로만 구성될 수 있다. 텍스트는 여기에 추가로 공백문자까지 포함할 수 있다.

입력의 끝에는 N = M = 0이 주어진다.

출력

각 테스트 케이스에 걸쳐, 한 줄에 하나씩 공백으로 대체해야 할 문자의 최소 개수를 출력한다.

예제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