{"raw_statement":[{"iden":"problem statement","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$."},{"iden":"constraints","content":"*   $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$."},{"iden":"input","content":"The 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$"},{"iden":"sample input 1","content":"3 3\n142857\n004159\n071028\n159\n287\n857"},{"iden":"sample output 1","content":"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$."},{"iden":"sample input 2","content":"5 4\n235983\n109467\n823476\n592801\n000333\n333\n108\n467\n983"},{"iden":"sample output 2","content":"3"},{"iden":"sample input 3","content":"4 4\n000000\n123456\n987111\n000000\n000\n111\n999\n111"},{"iden":"sample output 3","content":"3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}