#include <bits/stdc++.h>
int main(void) {
  double short_hand, long_hand, hour, min;
  double angle, ans;
  scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &min);
  angle = abs(hour * 30.0 + min / 2.0 - min * 6.0) / 180.0 * M_PI;
  ans = sqrt(pow(short_hand, 2.0) + pow(long_hand, 2.0) -
             2 * short_hand * long_hand * cos(angle));
  printf("%.9f\n", ans);
  return 0;
}
