#include <bits/stdc++.h>
using namespace std;
int main() {
  static const double pi = 3.141592653589793;
  int A, B;
  int H, M;
  cin >> A >> B >> H >> M;
  double thetah = pi * H / 6.0;
  double thetam = pi * M / 30.0;
  double theta = thetam - thetah;
  double dist = A * A + B * B - 2.0 * A * B * cos(theta);
  dist = sqrt(dist);
  cout << dist;
}
