#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, ta, b, tb, dt, h, m;
  cin >> a >> ta >> b >> tb;
  scanf("%d:%d", &h, &m);
  int x1 = h * 60 + m;
  int y1 = x1 + ta;
  int ans = 0;
  for (int x2 = 5 * 60 + 0; x2 < 24 * 60; x2 += b) {
    int y2 = x2 + tb;
    int x = max(x1, x2), y = min(y1, y2);
    if (x < y) ans++;
  }
  cout << ans << endl;
}
