#include <bits/stdc++.h>
using namespace std;
int min(int x, int y) { return (x < y) ? x : y; }
long double calcAngle(long double h, long double m) {
  if (h < 0 || m < 0 || h > 12 || m > 60) printf("Wrong input");
  if (h == 12) h = 0;
  if (m == 60) m = 0;
  long double hour_angle = 0.5 * (h * 60 + m);
  long double minute_angle = 6 * m;
  long double angle = abs(hour_angle - minute_angle);
  angle = min(360 - angle, angle);
  return angle;
}
int main() {
  long double a, b, h, m;
  long double d, x;
  cin >> a >> b >> h >> m;
  if (m == 0) {
    x = a * a + b * b;
    x = sqrt(x);
    cout << x;
  } else {
    d = calcAngle(h, m);
    d = (a * a) + (b * b) - 2.0 * a * b * cosl(d);
    d = sqrt(d);
    cout << d;
  }
}
