#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
void file() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  file();
  int a, ta, b, tb, th, tm, bus = 0;
  char ch;
  cin >> a >> ta >> b >> tb >> th >> ch >> tm;
  int ia = (th * 60) + tm, fa = (th * 60) + tm + ta;
  for (int i = 300; i <= 1439; i += b) {
    int f = i + tb;
    if (((i >= ia) && (i < fa)) || ((f > ia) && (f <= fa)) ||
        ((ia > i) && (fa < f)) || ((i > ia) && (fa > f)))
      bus++;
  }
  cout << bus;
}
