#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb;
string hour;
int main() {
  cin >> a >> ta;
  cin >> b >> tb;
  cin >> hour;
  int num = 0;
  int num2 = 0;
  int i;
  int last = 1139;
  for (i = 0; i < hour.length(); i++) {
    if ('0' <= hour[i] && hour[i] <= '9') {
      num = num * 10 + hour[i] - '0';
    } else if (hour[i] == ':') {
      num -= 5;
      break;
    }
  }
  for (; i < hour.length(); i++) {
    if ('0' <= hour[i] && hour[i] <= '9') {
      num2 = num2 * 10 + hour[i] - '0';
    }
  }
  num *= 60;
  num += num2;
  num2 = num + ta;
  int ans = 0;
  int start = 0;
  while (start < num2 && start <= last) {
    if (start + tb > num) ans++;
    start += b;
  }
  cout << ans << endl;
  return 0;
}
