#include "bits/stdc++.h"

using namespace std;
using ll = long long;

bool bs[1 << 17];
int nx[17][100000];

int main() {
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		string x; 
		cin >> x;
		int b = 0;
		for(char c : x) {
			b |= 1 << (c - 'a');
		}
		bs[b] = true;
	}

	string s;
	cin >> s;
	int m = s.size();

	for(int i = 1; i < 1 << 17; ++i) {
		if(bs[i]) {
			for(int j = 0; j < 17; ++j) {
				bs[i | (1 << j)] = true;
			}
		}
	}
	for(int i = 0; i < 17; ++i) {
		int lo = m;
		char c = 'a' + i;
		for(int j = m-1; j >= 0; --j) {
			if(s[j] == c) {
				lo = j;
			}
			nx[i][j] = lo;
			//cerr << "lo: " << lo << '\n';
		}
	}
	ll res = 0ll;
	for(int i = 0; i < m; ++i) {
		int b = 1 << (s[i] - 'a');
		vector<int> atts;
		for(int j = 0; j < 17; ++j) {
			atts.push_back(nx[j][i]);
		}
		sort(atts.begin(), atts.end());
		int en = i+1;
		for(int i = 0; i < 17; ++i) {
			if(bs[b]) break;
			if(atts[i] == m) break;
			en = atts[i]+1;
			b |= 1 << (s[atts[i]] - 'a');
		}
		if(!bs[b]) break;
		res += (m - en + 1);
	}
	
	cout << res << '\n';

	return 0;
}