#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  int h, m;
  cin >> h >> m;
  if (h == 0 && m == 0) cout << abs(a - b) << endl;
  float x = float(5.0 * m) / 60.0;
  float y = float(float(abs(m - h * 5.0 - x) * 90.0) / 15.0);
  float ang = cos(float(y * M_PI) / 180.0);
  float dis = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * ang);
  cout << dis << endl;
  return 0;
}
