#include <bits/stdc++.h>
using namespace std;
void Backspace(string& str)
{
for(int i = 0; i < str.length(); i++)
{
if(str[i] == '<')
{
for(int j = 0; j < str.length() - i - 1; j++)
{
str[i + (j - 1 + !(i > 0))] = str[i + (j + 1)];
}
str.erase(str.length() - 1 - (i > 0));
i -= 1 + (i > 0);
}
}
}
void Input(string& str)
{
bool isInputting = true;
string rawInput = "";
int strLength = 0;
while(isInputting)
{
getline(cin, rawInput);
Backspace(rawInput);
str += rawInput + '\n';
strLength += rawInput.length() + 1;
if(str[strLength - 5] == '\n' && str[strLength - 4] == 'E' && str[strLength - 3] == 'O' && str[strLength - 2] == 'F' && str[strLength - 1] == '\n')
{
strLength = 0;
rawInput = "";
str.erase(str.length() - 4);
isInputting = false;
}
}
}
int main()
{
string rawInput = "", sample = "", input = "";
int strLength = 0;
bool isInputting = true;
Input(sample);
isInputting = true;
Input(input);
int rightApb = 0, _inputCount = 0;
for(int i = 0; i < sample.length(); i++)
{
if(input[_inputCount] == '\0' && _inputCount > 0) i = sample.length();
else
{
if(input[_inputCount] == sample[i] && sample[i] != '\n')
{
rightApb ++;
}
else if(sample[i] == '\n' && input[_inputCount] != '\n')
{
while(input[_inputCount] != '\n' && input[_inputCount] != '\0')
{
_inputCount ++;
}
}
_inputCount ++;
}
}
int time;
cin >> time;
cout << int(rightApb * 60 / time + 0.5);
return 0;
}