#include <string>
#include <vector>
using namespace std;
bool check(string s, string skill) {
int i;
for (i = 0; i < skill.size() - 1; i++) {
string tmp1 = "";
string tmp2 = "";
tmp1.push_back(skill[i]);
tmp2.push_back(skill[i + 1]);
if (s.find(tmp1) == string::npos) {
if (s.find(tmp2) != string::npos) return false;
}
else {
if (s.find(tmp1) > s.find(tmp2)) return false;
}
}
return true;
}
int solution(string skill, vector<string> skill_trees) {
int answer = 0;
for (string s : skill_trees) {
if (check(s, skill)) answer++;
}
return answer;
}