#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000001;
int main() {
  int y = 5 * 60;
  int z = 23 * 60 + 59;
  int a, ta, b, tb;
  cin >> a >> ta >> b >> tb;
  int hh, mm;
  scanf("%d:%d", &hh, &mm);
  int x = hh * 60 + mm;
  int ans = 0;
  for (int i = 0;; i++) {
    int st = i * b + y;
    if (st > z) break;
    if (st + tb > x && st < x + ta)
      ans++;
    else if (st >= x + ta)
      break;
  }
  cout << ans << endl;
  return 0;
}
