// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-6
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
using namespace std;
// mylittledoge

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	vector<string> V(N);
	for(int i =0; i < N; i++) cin >> V[i];
	sort(V.begin(),V.end());
	string S;
	cin >> S;
	int L =S.length();
	vector<int> ans(L+1,L+1);
	ans[0] =0;
	for(int i =0; i < L; i++) {
		ans[i+1] =min(ans[i+1],ans[i]+1);
		int t =0;
		for(int j =0; j < N; j++) if(V[j].length() >= i && V[j].substr(0,i) == S.substr(0,i)) {
			t++;
			if(S.length() >= V[j].length() && S.substr(0,V[j].length()) == V[j])
				ans[V[j].length()] =min(ans[V[j].length()],ans[i]+t);
			}
		}

	cout << ans[L]+1 << "\n";
	return 0;}

// look at my code
// my code is amazing