#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  int a, ta, b, tb, h, m;
  char ch;
  cin >> a >> ta >> b >> tb;
  cin >> h >> ch >> m;
  int srt = h * 60 + m;
  int end = srt + ta;
  int ans = 0;
  for (int cur = 5 * 60; cur < 24 * 60; cur += b) {
    if (cur <= srt && cur + tb > srt)
      ans++;
    else if (cur >= srt && cur < end)
      ans++;
  }
  cout << ans;
}
