#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 5, M = 100 + 5, OO = 0x3f3f3f3f, MOD = 1e9 + 9, base = 131,
          MOD2 = 1000136437;
string s, t;
map<string, bool> forb;
int memo[27][N];
int solve(int c = 26, int idx = 0) {
  if (idx == (int)(s).size()) return 0;
  int &ret = memo[c][idx];
  if (~ret) return ret;
  ret = solve(c, idx + 1) + 1;
  if (c != 26) {
    t = (c + 'a');
    t += s[idx];
  } else
    t = s[idx];
  if (c == 26 || !forb[t]) ret = min(solve(s[idx] - 'a', idx + 1), ret);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset((memo), (-1), sizeof(memo));
  ;
  int n;
  cin >> s >> n;
  while (n--) {
    cin >> t;
    forb[t] = true;
    reverse((t).begin(), (t).end());
    forb[t] = true;
  }
  cout << solve();
  return 0;
}
