#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  h *= 30;
  h += m / 2;
  m *= 6;
  double ans;
  double kbir = ((h > m) ? h : m);
  double sghir = ((h > m) ? m : h);
  double zaw = (((kbir - sghir) > 180) ? 360 - (kbir - sghir) : (kbir - sghir));
  double e = static_cast<double>(((a >= b) ? a : b));
  double f = static_cast<double>(((a >= b) ? b : a));
  double tmp = cos(zaw * 3.141592653589793 / 180) * f;
  tmp = e - tmp;
  double tmpo = sin(zaw * 3.141592653589793 / 180) * f;
  ans = sqrt(tmp * tmp + tmpo * tmpo);
  cout << ans << '\n';
}
