#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
signed main() {
  const double pi = 3.141592653589793;
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double k = m * 6;
  long double l = (30 * h) + (0.5 * m);
  if (k == l) {
    cout << max(a, b) - min(a, b);
    return 0;
  }
  if (k == 0 && l >= 30) k = 360;
  if (l == 0 && k >= 30) l = 360;
  long double ang = max(k, l) - min(k, l);
  if (ang == 180) {
    cout << a + b;
    return 0;
  }
  long double c = cos(pi / (180 / ang));
  long double a2 = a * a;
  long double b2 = b * b;
  long double ans = a2 + b2 - (2 * a * b * c);
  cout << fixed << setprecision(15);
  cout << sqrt(ans);
  return 0;
}
