#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  int H;
  cin >> H;
  int M;
  cin >> M;
  double hx, hy;
  double angleH = -1 * M_PI / 6 * H + M_PI / 2 + (-1 * M_PI / 360 * M);
  hx = A * cos(angleH);
  hy = A * sin(angleH);
  double mx, my;
  double angleM = -1 * M_PI / 30 * M + M_PI / 2;
  mx = B * cos(angleM);
  my = B * sin(angleM);
  double length = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));
  cout << length << endl;
  return 0;
}
