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