#include <iostream>
#include <string>
int timeToSeconds(const std::string& timeStr) {
int hours, minutes, seconds;
sscanf(timeStr.c_str(), "%d:%d:%d", &hours, &minutes, &seconds);
return hours * 3600 + minutes * 60 + seconds;
}
int main() {
std::string start_time, end_time;
int n;
std::cin >> start_time >> end_time >> n;
int start_seconds = timeToSeconds(start_time);
int end_seconds = timeToSeconds(end_time);
int time_diff = end_seconds - start_seconds;
int notebooks = n * time_diff;
std::cout << notebooks << std::endl;
return 0;
}