#include <bits/stdc++.h>
const int N = 0;
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double a, b, H, M;
  cin >> a >> b >> H >> M;
  double ang1 =
      (H * 2 * (double)acos(-1)) / 12 + (M * 2 * (double)acos(-1) / 60) / 12;
  double ang2 = (M * 2 * (double)acos(-1)) / 60;
  double ang = abs(ang1 - ang2);
  double ans = 0;
  if (ang == (double)acos(-1)) {
    ans = a + b;
  } else if (ang > (double)acos(-1)) {
    ang = 2 * (double)acos(-1) - ang;
  }
  if (ans == 0) {
    ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(ang));
  }
  printf("%20.20f\n", ans);
  return 0;
}
