#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, h, m;
  cin >> a >> b >> h >> m;
  h *= 5;
  long double x = abs(h - m) + m / 12.0;
  x = min(x, 60 - x);
  if (x == 30) {
    cout << a + b << '\n';
    return;
  }
  if (x == 0) {
    cout << abs(a - b);
    return;
  }
  x = (x * 2 * M_PI) / 60.0;
  long double c = a * a + b * b - 2 * a * b * cos(x);
  cout << setprecision(20) << sqrt(c);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1, an = 1;
  while (TESTS--) {
    an++;
    solve();
  }
  return 0;
}
