#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a;
  cin >> b;
  cin >> h;
  cin >> m;
  int min = h * 60 + m;
  double theta_a = M_PI / 360 * min;
  double theta_b = M_PI / 30 * min;
  double d_theta = theta_b - theta_a;
  if (d_theta == 0) {
    printf("%.16lf\n", b - a);
    return 0;
  } else if (d_theta == M_PI / 2) {
    printf("%.16lf\n", b + a);
    return 0;
  } else if (d_theta > M_PI / 2) {
    d_theta = 2 * M_PI - d_theta;
  }
  double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(d_theta));
  printf("%.16lf\n", ans);
  return 0;
}
