#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int q[N];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  if ((h + 6 == m / 5) || (h - 6 == m / 5)) {
    cout << a + b;
    return 0;
  }
  double pi = acos(-1.0);
  double M = m / 30 * pi;
  double H = h / 6 * pi + m * pi / 360;
  double jiao = abs(M - H);
  if (jiao > pi) jiao -= pi;
  printf("%.20f", sqrt(a * a + b * b - 2 * a * b * cos(jiao)));
}
