#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, x, y, sum, A, AA, B, BB;
char ch;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> a >> ta >> b >> tb >> x >> ch >> y;
  A = 60 * x + y;
  AA = A + ta;
  for (int i = 5 * 60; i <= 1439; i += b) {
    B = i;
    BB = B + tb;
    int maxx = max(A, B);
    int mini = min(AA, BB);
    if (maxx < mini) sum++;
  }
  cout << sum << endl;
  return 0;
}
