{"problem":{"name":"Postal Card","description":{"content":"You are given $N$ strings of length six each, consisting of digits. Let $S_i$ be the $i$\\-th $(i = 1, 2, \\dots, N)$ of them. You are also given $M$ strings of length three each, consisting of digits. ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc287_b"},"statements":[{"statement_type":"Markdown","content":"You are given $N$ strings of length six each, consisting of digits. Let $S_i$ be the $i$\\-th $(i = 1, 2, \\dots, N)$ of them.\nYou are also given $M$ strings of length three each, consisting of digits. Let $T_j$ be the $j$\\-th $(j = 1, 2, \\dots, M)$ of them.\nFind the number of strings among $S_1, S_2, \\dots, S_N$ whose last three characters coincide with one or more of $T_1, T_2, \\dots, T_M$.\n\n## Constraints\n\n*   $1 \\leq N, M \\leq 1000$\n*   $N$ and $M$ are integers.\n*   $S_i$ is a string of length $6$ consisting of digits, for all $i = 1, 2, \\dots, N$.\n*   $T_j$ is a string of length $3$ consisting of digits, for all $j = 1, 2, \\dots, M$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$\n$T_1$\n$T_2$\n$\\vdots$\n$T_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc287_b","tags":[],"sample_group":[["3 3\n142857\n004159\n071028\n159\n287\n857","2\n\nThe last three characters of $S_1$ are `857`, which coincide with $T_3$.  \nThe last three characters of $S_2$ are `159`, which coincide with $T_1$.  \nThe last three characters of $S_3$ are `028`, which do not coincide with $T_1$, $T_2$, or $T_3$.\nThus, the answer is $2$."],["5 4\n235983\n109467\n823476\n592801\n000333\n333\n108\n467\n983","3"],["4 4\n000000\n123456\n987111\n000000\n000\n111\n999\n111","3"]],"created_at":"2026-03-03 11:01:14"}}