#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ta, tb, h, m, mall, count = 0;
  vector<int> bus;
  char d;
  cin >> a >> ta >> b >> tb >> h >> d >> m;
  for (int i = 300; i < 1440; i += b) {
    bus.push_back(i);
  }
  mall = h * 60 + m;
  for (int i = 0; i < bus.size(); i++) {
    for (int j = 0; j < tb; j++) {
      if (bus[i] + j >= mall && bus[i] + j < mall + ta) {
        count++;
        break;
      }
    }
  }
  cout << count;
  return 0;
}
