#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ta, tb, h, m, i, ans = 0;
  cin >> a >> ta >> b >> tb;
  scanf("%d:%d", &h, &m);
  h *= 60;
  h += m;
  h -= 300;
  for (i = 0; b * i < 1140; i++) {
    if (b * i + tb > h && b * i < h + ta) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
