#include <bits/stdc++.h>
using namespace std;
void solve() {
  long double a, b, h, m, angh, angm, fang, ans;
  long double val;
  cin >> a >> b >> h >> m;
  cout << fixed << setprecision(10);
  angh = 30 * h;
  angm = 6 * m;
  angh += (0.5 * m);
  fang = abs(angh - angm);
  fang = min(fang, 360 - fang);
  if (fang == 90)
    val = 0;
  else if (fang == 0 || fang == 180)
    val = 1;
  else {
    fang *= (3.14159265358979323846 / 180);
    val = cos(fang);
  }
  ans = (a * a) + (b * b) - (2 * a * b * val);
  cout << sqrt(ans) << '\n';
  cin >> a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int T = 1;
  while (T--) solve();
  return 0;
}
