#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb;
int h, m;
char c;
int main() {
  cin >> a >> ta >> b >> tb >> h >> c >> m;
  int t = h * 60 + m;
  int tinf = t - tb + 1;
  int tsup = t + ta - 1;
  int sol = 0;
  for (int sal = 5 * 60; sal < 24 * 60; sal += b)
    sol += tinf <= sal and sal <= tsup;
  cout << sol << endl;
}
