#include <bits/stdc++.h>
int main() {
  long double a, b, h, m;
  long double d1, d2, xs, ys, xl, yl;
  long double PI, dis;
  PI = 3.141592653589793238462643L;
  scanf("%Lf %Lf %Lf %Lf", &a, &b, &h, &m);
  xs = a * (long double)sin(PI * (30.0L * h + m / 2.0L) / 180.0L);
  ys = a * (long double)cos(PI * (30.0L * h + m / 2.0L) / 180.0L);
  xl = b * (long double)sin(PI * (6.0L * m / 180.0L));
  yl = b * (long double)cos(PI * (6.0L * m / 180.0L));
  dis = (long double)pow(
      (long double)pow((xs - xl), 2L) + (long double)pow((ys - yl), 2L), 0.5L);
  printf("%.30Lf", dis);
  return 0;
}
