#include<bits/stdc++.h>
using namespace std;
string a[100010], b[100010], c[100010];
int cnt, cnt1;
string ers(string s, int l, int r) {
int n = s.size();
return s.substr(0, l) + s.substr(r + 1, n - r);
}
int main() {
string s1, s2;
while (getline(cin, s1) && s1 != "EOF") {
a[++cnt1] = s1;
}
while (getline(cin, s2) && s2 != "EOF") {
b[++cnt] = s2;
}
for (int i = 1; i <= cnt; i ++) {
string s = "";
for (unsigned j = 0; j < b[i].size(); j ++) {
if (b[i][j] != '<') s += b[i][j];
else s = s.substr(0, s.size() - 1); // 删掉一位
}
b[i] = s;
}
int ans = 0;
for (int i = 1; i <= cnt; i ++) {
for (unsigned j = 0; j < b[i].size(); j ++) {
//cout << a[i][j] << " " << b[i][j] << endl;
if (a[i][j] == b[i][j]) ans ++;
}
}
int tm;
cin >> tm;
ans = ans * 60;
cout << round(ans * 1.0 / tm) << endl;
return 0;
}
40pts WA???