#include <bits/stdc++.h>
const long double PI = acos(-1);
const long double eps = 0.0000000001;
const long long INF = 0x3fffffffffffffff;
long long dis[2505], n;
std::vector<long long> to[2505];
std::string s[55], t;
std::queue<long long> que;
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  for (long long i = 1; i <= n; ++i) std::cin >> s[i];
  std::cin >> t;
  std::fill(dis + 1, dis + 1 + t.size(), -1);
  for (long long i = 1; i <= n; ++i)
    for (long long j = 0; j != (long long)t.size(); ++j) {
      long long l = j;
      for (long long k = 0; k != (long long)s[i].size(); ++k)
        if (t[l] == s[i][k]) ++l;
      if (j != l) to[j].push_back(l);
    }
  que.push(0);
  while (!que.empty()) {
    long long now = que.front();
    que.pop();
    for (auto i : to[now])
      if (!~dis[i]) dis[i] = dis[now] + 1, que.push(i);
  }
  std::cout << dis[t.size()] << std::endl;
  return 0;
}
