#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double teta = (h + m / 60) * 11 * M_PI / 6;
  long double dist = sqrt(a * a + b * b - 2 * a * b * cos(teta));
  cout << setprecision(15) << dist;
  return 0;
}
