#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ta, tb, q;
  char str[5];
  scanf("%d%d", &a, &ta);
  scanf("%d%d", &b, &tb);
  q = tb;
  scanf("%s", str);
  tb = q;
  int hou = (str[0] - '0') * 10 + (str[1] - '0');
  int mit = (str[3] - '0') * 10 + (str[4] - '0');
  int x0 = ((hou - 5) * 60 + mit), x1 = x0 % b, x2,
      x3 = (23 - hou) * 60 + 59 - mit;
  x2 = x1;
  int ans = 0;
  while (x1 < tb) {
    if (x1 > x0) break;
    ans++;
    if (x1 == 0) ans--;
    x1 += b;
  }
  x1 = b - x2;
  while (x1 < ta) {
    if (x1 > x3) break;
    if (x1 == b) ans++;
    x1 += b;
    ans++;
  }
  if (x2 == 0 && x1 == b - x2) ans++;
  printf("%d\n", ans);
  return 0;
}
