#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
map<string, bool> m;
const long long int N = 1e5 + 5;
long long int dp[N][30];
string s;
long long int solve(long long int i, long long int x, long long int n) {
  if (i >= n) {
    return 0;
  }
  long long int &ans = dp[i][x];
  if (ans != -1) {
    return ans;
  }
  long long int res = 1e18;
  string temp = "";
  temp += s[i];
  temp += x + 'a';
  if (!m[temp]) {
    res = min(res, solve(i + 1, s[i] - 'a', n));
  }
  res = min(res, 1 + solve(i + 1, x, n));
  return ans = res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(dp, -1, sizeof(dp));
  cin >> s;
  long long int n;
  cin >> n;
  while (n--) {
    string k;
    cin >> k;
    m[k] = true;
    reverse(k.begin(), k.end());
    m[k] = true;
  }
  cout << solve(0, 27, s.length()) << "\n";
  return 0;
}
