#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  int time = h * 60 + m;
  int degh = (time / 2) % 360;
  int degm = (time * 6) % 360;
  double theta = abs(degh - degm);
  theta = (theta * 3.14159265) / (180.0);
  double ans = sqrt(a * a + b * b - cos(theta) * 2 * a * b);
  cout << fixed << setprecision(20) << ans;
  return 0;
}
