#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
const int N = 10005;
string text[N], input[N],s;
int i = 0;
while (1)
{
getline(cin, s);
if (s == "EOF")
break;
for (char o : s)
{
if (o == '<')
text[i].pop_back();
if (o >= 'a' && o <= 'z' || o == ' ' || o >= '1' && o <= '9' || o == '.')
{
text[i].push_back(o);
}
}
i++;
}
int i1 = 0;
while (1)
{
getline(cin, s);
if (s == "EOF")
break;
for (char o : s)
{
if (o == '<')
input[i1].pop_back();
if (o >= 'a' && o <= 'z' || o == ' ' || o >= '1' && o <= '9' || o == '.')
{
input[i1].push_back(o);
}
}
i1++;
}
int N1 = 0;
int Time;
scanf("%d", &Time);
for (int o = 0; o < i; o++)
{
for (size_t p = 0; p < min(text[o].length(),input[o].length()); p++)
{
if (text[o][p] == input[o][p])
N1++;
}
}
double KPS;
KPS = (N1 * 1.0 / Time) * 60;
KPS += 0.5;
printf("%d", (int)KPS);
}