#include <bits/stdc++.h>
using namespace std;
long double PI = 3.14159265;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double p, q, r, s, tt, uu, vv, ww, angle, ans;
  p = h * 1.00 * 30;
  q = ((long double)m / 60.00) * 30.00;
  r = p + q;
  s = (long double)m * 6.00;
  if (r >= s) {
    tt = ((r - s) * PI) / 180.00;
    angle = cos(tt);
    uu = (a) * (a)*1.00 + (b) * (b)*1.00 - 2.00 * a * b * angle;
    vv = sqrtl(uu);
    printf("%.20Lf\n", vv);
    return 0;
  } else {
    tt = ((s - r) * PI) / 180.00;
    angle = cos(tt);
    uu = (a) * (a)*1.00 + (b) * (b)*1.00 - 2.00 * a * b * angle;
    vv = sqrtl(uu);
    printf("%.20Lf\n", vv);
    return 0;
  }
}
