#include #define rep(i, a, n) for(int i = a; i < n; i++) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long using namespace std; typedef pair P; signed main(){ string s; int m; cin >> s >> m; vector c(m); rep(i, 0, m){ cin >> c[i]; } int ans = 0; rep(i, 0, m){ int pos = s.find(c[i], 0); while(pos != string::npos){ ans++; pos = s.find(c[i], pos + 1); } } cout << ans << endl; }