1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #include<string>
5 using namespace std;
6 int n,l,len[605],f[605];
7 char str[605],ch[605][30];
8 inline int cal(int x,int len,int y){
9 int tot=0;
10 int l1=x,l2=1;
11 while(l1<=l){
12 if(str[l1]==ch[y][l2])l2++;
13 else tot++;
14 if(l2==len+1)return tot;
15 l1++;
16 }
17 return -1;
18 }
19 int main(){
20 scanf("%d%d",&n,&l);
21 scanf("%s",str+1);
22 for(int i=1;i<=n;i++)
23 scanf("%s",ch[i]+1);
24 for(int i=l;i;i--){
25 f[i]=f[i+1]+1;
26 for(int j=1;j<=n;j++){
27 int Len=strlen(ch[j]+1);
28 int t=cal(i,Len,j);
29 if(t!=-1)f[i]=min(f[i],f[i+Len+t]+t);
30 }
31 }
32 printf("%d",f[1]);
33 return 0;
34 }