#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double a, b, h, m, ang, ans;
  cin >> a >> b;
  cin >> h >> m;
  ang = 3.14159265358979323846264338327950L * 2 *
        ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);
  ans = (double)(a * a + b * b) - (double)(2 * a * b) * cosl(ang);
  printf("%20.20Lf\n", sqrtl(ans));
  return 0;
}
