#include <bits/stdc++.h>
using namespace std;
const int INFL = (int)1e9;
const long long int INFLL = (long long int)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
long long int rndf(double x) {
  return (long long int)(x + (x >= 0 ? 0.5 : -0.5));
}
long long int floorsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (m * m <= x ? 0 : -1);
}
long long int ceilsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (x <= m * m ? 0 : 1);
}
long long int rnddiv(long long int a, long long int b) {
  return (a / b + (a % b * 2 >= b ? 1 : 0));
}
long long int ceildiv(long long int a, long long int b) {
  return (a / b + (a % b == 0 ? 0 : 1));
}
long long int gcd(long long int m, long long int n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
long long int lcm(long long int m, long long int n) {
  return m * n / gcd(m, n);
}
int solve(const string &s, int p, const string &t) {
  for (int i = 0; i < (int)(t.length()); i++) {
    if (p == s.length()) break;
    if (s[p] == t[i]) p++;
  }
  return p;
}
int main() {
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < (int)(m); i++) cin >> t[i];
  string s;
  cin >> s;
  int n = s.length();
  vector<int> dp(n + 1, INT_MAX);
  dp[0] = 0;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (dp[i] == INT_MAX) continue;
    for (int j = 0; j < (int)(m); j++) {
      int next_i = solve(s, i, t[j]);
      dp[next_i] = min(dp[next_i], dp[i] + 1);
    }
  }
  if (dp[n] == INT_MAX) {
    cout << -1 << endl;
  } else {
    cout << dp[n] << endl;
  }
}
