#include<bits/stdc++.h>
using namespace std;
int t,i,ls1,ls2,a;
string s;
stack<char>s1[1001],s2;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(getline(cin,s)) {
i++;
if(s=="EOF")break;
for(int j=0; j<s.size(); j++){s1[i].push(s[j]);}
}
i=0;
while(getline(cin,s)) {
i++;
if(s=="EOF")break;
for(int j=0; j<s.size(); j++) {
if(s[j]=='<'&&!s2.empty())s2.pop();
else s2.push(s[j]);
}
ls1=s1[i].size();
ls2=s2.size();
if(ls1>ls2) {
while(s1[i].size()>ls2)s1[i].pop();
} else if(ls2>ls1) {
while(s2.size()>ls1)s2.pop();
}
while(!s2.empty()) {
if(s1[i].top()==s2.top())a++;
s1[i].pop();
s2.pop();
}
}
cin>>t;
cout<<int(a*60.0/t+0.5)<<endl;
return 0;
}