#include <bits/stdc++.h>
using namespace std;
int cost[3000], n;
string in[55], s;
int main() {
  cin >> n;
  memset(cost, 1, sizeof(cost));
  for (int i = 0; i < n; i++) cin >> in[i];
  cin >> s;
  s = '#' + s;
  int L = s.size();
  cost[0] = 0;
  for (int i = 0; i < L; i++) {
    int c = cost[i] + 1;
    for (int j = 0; j < n; j++) {
      int lj = in[j].size();
      for (int k = 0, l = 1; k < lj && i + l < L; k++)
        if (in[j][k] == s[i + l]) cost[i + l] = min(cost[i + l], c), l++;
    }
  }
  if (cost[L - 1] == 16843009) cost[L - 1] = -1;
  cout << cost[L - 1] << endl;
}
