#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double thetaa = 2 * M_PI * (h * 60 + m) / 720;
  double thetab = 2 * M_PI * m / 60;
  double theta = thetab - thetaa;
  double c = a * a + b * b - 2 * a * b * cosl(theta);
  c = sqrtl(c);
  cout << c << endl;
  return 0;
}
