#include <bits/stdc++.h>
using namespace std;
int main() {
  static const double pi = 3.141592653589793238462643383279;
  int A;
  int B;
  int H;
  int M;
  cin >> A >> B >> H >> M;
  double ax = sin(pi * H / 6) * A;
  double ay = cos(pi * H / 6) * A;
  double bx = sin(pi * M / 30) * B;
  double by = cos(pi * M / 30) * B;
  double h = ay - by;
  double w = ax - bx;
  double ans = sqrt(h * h + w * w);
  printf("%20.20f", ans);
}
