#include <stdio.h> #include <stdlib.h> double pi = 3.1415926535898; int main(int argc, char *argv[]) { int p, e, i, d; int k1, k2, k3; int days; int cnt = 1; while (true) { scanf("%d %d %d %d", &p, &e, &i, &d); if (p==-1 && e==-1 && i==-1 && d==-1) break; p = p % 23; e = e % 28; i = i % 33; k1 = k2 = k3 = 0; days = (5544 * p + 14421 * e + 1288 * i - d) % (21252); if (days <= 0) { days = 23 * 28 * 33 + days; } printf("Case %d: the next triple peak occurs in %d days.\n", cnt++, days); } return 0; }