#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){

  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int Mstart = H1 * 60 + M1;
  int Mend = H2 * 60 + M2;
  int t = (Mend - Mstart) / K;

  cout << K * t << endl;
  return 0;
}
