#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s1[10010], s2[10010], tmp;
int T, cnt, n = -1, m = -1;
int main()
{
while (1)
{
getline(cin, tmp);
if (tmp == "EOF")
break;
n++;
int t=tmp.size();
for (int i = 0; i < t; i++)
{
if (tmp[i] == '<' and !s1[n].empty())
s1[n].pop_back();
else if (tmp[i] != '<' and ((tmp[i]>='a' and tmp[i]<='z')or (tmp[i]==' ') or (tmp[i]=='.')))
s1[n].push_back(tmp[i]);
}
}
while (1)
{
getline(cin, tmp);
if (tmp == "EOF")
break;
if (m>n)
break;
m++;
int t=tmp.size();
for (int i = 0; i < t; i++)
{
if (tmp[i] == '<' and !s1[m].empty())
s2[m].pop_back();
else if (tmp[i] != '<' and ((tmp[i]>='a' and tmp[i]<='z')or (tmp[i]==' ') or (tmp[i]=='.')))
s2[m].push_back(tmp[i]);
}
t=min(s1[m].size(),s2[m].size());
for(int i=0;i<t;i++)
{
if(s2[m][i]==s1[m][i])
cnt++;
}
}
scanf("%d",&T);
long long l=(cnt*60.0/T+0.5);
cout<<l;
return 0;
}
