#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double ans = 0;
  double pi = acos(-1);
  double a = 2 * pi * double(H * 60 + M) / 720;
  double b = 2 * pi * double(M) / 60;
  double r = 0;
  if (a - b > 180) {
    r = 360 - a - b;
  } else {
    r = a - b;
  }
  ans = sqrt(A * A + B * B - 2 * A * B * cos(r));
  cout << ans << endl;
  return 0;
}
