#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000;
const long long LINF = (long long)INF * INF;
int a, ta, b, tb;
char hm[20];
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> a >> ta >> b >> tb;
  cin >> hm;
  int h = hm[1] - '0' + (hm[0] - '0') * 10;
  int m = (hm[3] - '0') * 10 + hm[4] - '0';
  h -= 5;
  m += 60 * h;
  ;
  ;
  int ans = 0;
  for (int i = 0; i <= 18 * 60 + 59; i += b) {
    if (m - tb < i && i < m + ta) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
