#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  double rh, rm, rd, c;
  cin >> A >> B >> H >> M;
  rh = 2 * M_PI * H / 12.0 + 2 * M_PI / 12.0 / 60.0 * M;
  rm = 2 * M_PI * M / 60.0;
  rd = rh - rm;
  if (rd < 0) rd = -rd;
  if (rd > M_PI) rd = 2 * M_PI - rd;
  c = A * A + B * B - (2 * A * B * cos(rd));
  c = sqrt(c);
  if (rd == 0) c = 0;
  cout << c << endl;
}
