#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long fast_exp(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return res % MOD;
}
long long solve(string A, string s) {
  unordered_map<char, long long> um;
  for (long long i = 0; i < A.size(); i++) um[A[i]]++;
  vector<long long> freq(27);
  s += "B";
  long long i = 0, ans = 0;
  while (i < s.size()) {
    if (um.count(s[i])) {
      freq[s[i] - 'a']++;
    } else {
      long long maxi = 1e9;
      for (auto ch : um) {
        maxi = min(maxi, freq[ch.first - 'a']);
      }
      ans += maxi;
      for (long long i = 0; i < 27; i++) freq[i] = 0;
    }
    i++;
  }
  return ans;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  long long k;
  cin >> k;
  vector<string> A(k);
  for (long long i = 0; i < k; i++) cin >> A[i];
  long long ans = 0;
  for (long long i = 0; i < k; i++) {
    ans += solve(A[i], s);
  }
  cout << ans << endl;
  return 0;
}
