#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

#define PB push_back
#define ST first
#define ND second

const int maxl = 1000;
set<ll> s[maxl];
const int maxn = 3e5+100;
ll h[maxn];
ll po[maxn];
ll dp[maxn];
int n;
const int mod = 1e9+7;
const ll base=29;

void preCompute(string &cc)
{
	h[0] = 0;
	po[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		po[i] = (po[i-1]*base)%mod;
	}
	for(int i=1; i <= n; i++)
	{
		h[i] = (h[i-1] + cc[i-1]*po[i])%mod;
	}
}

ll getHash(int i, int j)
{
	ll res = (h[j] - h[i-1]) * po[n-i];
	res = (res%mod+mod)%mod;
	return res;
}

ll toHash(string c)
{
	ll res=0;
	int m = c.size();
	for(int i=1; i <= m; i++)
	{
		res=(res+po[i]*c[i-1])%mod;
	}
	res = ((res*po[n-1])%mod+mod)%mod;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int m;
	cin >> m;
	string cc;
	cin >> cc;
	n = cc.size();
	preCompute(cc);
	vector<string> v;
	map<int, int> mapa;
	vector<int> d;
	for(int i = 0; i < m; i++)
	{
		string c;
		cin >> c;
		d.PB(c.size());
		v.PB(c);
	}
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());
	vector<int> g;
	int nr=0;
	mapa[d[0]] = nr++;
	g.PB(d[0]);
	for(int i=1; i < d.size(); i++)
	{
		if(d[i-1] != d[i])
		{
			mapa[d[i]] = nr++;
			g.PB(d[i]);
		}
	}
	d = g;
	for(string c : v)
	{
		int id = mapa[c.size()];
		s[id].insert(toHash(c));
	}
	for(int i=1; i <= n; i++)
	{
		int j=0;
		for(int e : d)
		{
			if(i+e-1 > n)
			{
				j++;
				continue;
			}
			ll f = getHash(i, i+e-1);
			if(s[j].count(f))
			{
				dp[i] = i+e-1;
				break;
			}
			j++;
		}
	}
	int res=1;
	int maxd = dp[1];
	int j = 1;
	for(int i=1; i <= n; i++)
	{
		//~ cout << i << " " << dp[i] << "\n";
	}
	while(j <= n)
	{
		//~ cout << "\t" << j << " " << maxd << endl;
		if(maxd >= n)
			break;
		ll nextm = 0;
		while(j <= maxd+1)
		{
			nextm = max(nextm, dp[j]);
			j++;
		}
		if(nextm <= maxd)
		{
			cout << "-1\n";
			return 0;
		}
		maxd = nextm;
		res++;
	}
	cout << res << "\n";
	return 0;
}


