#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
bool contains(const string& block, const string& s, int start, int end) {
  if (end - start + 1 > int(block.size())) return false;
  int j = 0;
  for (int i = start; i <= end; i++) {
    while (j < int(block.length()) && block[j] != s[i]) {
      j++;
    }
    if (j == int(block.length())) return false;
    j++;
  }
  return true;
}
void minimize(int& x, int val) {
  if (val < x) x = val;
}
int main() {
  int n;
  cin >> n;
  vector<string> blocks(n);
  for (int i = 0; i < n; i++) {
    cin >> blocks[i];
  }
  string s;
  cin >> s;
  int m = s.length();
  vector<int> dp(m, INF);
  for (int i = 0; i < m; i++) {
    for (const auto& b : blocks) {
      if (int(b.length()) >= i + 1 && contains(b, s, 0, i)) {
        minimize(dp[i], 1);
      }
    }
    for (int j = i; i - j <= 50 && j >= 1; j--) {
      if (dp[j - 1] == INF) continue;
      for (const auto& b : blocks) {
        if (contains(b, s, j, i)) {
          minimize(dp[i], dp[j - 1] + 1);
          break;
        }
      }
    }
  }
  if (dp[m - 1] >= INF) {
    cout << -1 << endl;
  } else {
    cout << dp[m - 1] << endl;
  }
}
