#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
void solve() {
  int a, ta, b, tb;
  char s[10];
  cin >> a >> ta >> b >> tb;
  scanf("%s", s);
  int h = 0, m = 0;
  m += s[4] - '0';
  m += (s[3] - '0') * 10;
  m += ((s[0] - '0') * 10 + (s[1] - '5')) * 60;
  int ms = 0, me = 0;
  ms = m;
  me = ms + ta;
  int cs = 0, ce = 0;
  int count = 0;
  cs = 0, ce = tb;
  for (int i = 0; i <= 1500; i++) {
    if (cs > 1139) break;
    if ((ce > ms && ce <= me) || (cs >= ms && cs < me) ||
        (cs <= ms && ce >= me))
      count++;
    cs += b;
    ce = cs + tb;
    printf("\n");
  }
  printf("%d\n", count);
}
int main() {
  solve();
  return 0;
}
