#include <bits/stdc++.h>
using namespace std;
int mem[2600];
int INF = 1000000000;
int N;
string str[60];
string fav;
int pick(string& s, string& fav, int n) {
  int i = n;
  int j = 0;
  while (i < fav.length() && j < s.length()) {
    if (fav[i] == s[j]) {
      i++;
    }
    j++;
  }
  return i - n;
}
int dp(int n) {
  int& cache = mem[n];
  if (cache != -1) return cache;
  if (n == fav.length()) return 0;
  int best = INF;
  for (int i = 0; i < N; i++) {
    int x = pick(str[i], fav, n);
    if (x > 0) {
      best = min(best, 1 + dp(n + x));
    }
  }
  cache = best;
  return cache;
}
int main() {
  fill_n(mem, 2510, -1);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> str[i];
  cin >> fav;
  int soln = dp(0);
  cout << ((soln == INF) ? -1 : soln);
  return 0;
}
