#include <bits/stdc++.h>
using namespace std;
double calculate();
int main() {
  double len = calculate();
  cout << len << endl;
  return 0;
}
double calculate() {
  static const double pi = 3.14159265358979323846;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double deg_m = 6 * m;
  double deg_h = (30 * h) + (1 / 2) * m;
  double len =
      sqrt(a * a + b * b - 2 * a * b * cos((deg_m - deg_h) * pi / 180));
  return len;
}
