#include <bits/stdc++.h>
constexpr int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
long long int combi(long long int n, long long int r) {
  if (r == 0 || r == n)
    return 1;
  else
    return combi(n - 1, r) + combi(n - 1, r - 1);
}
long long int sigma1(long long int n) { return n * (n + 1) / 2; }
long long int sigma2(long long int s, long long int n) {
  return sigma1(n) - sigma1(s - 1);
}
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double gosa = (m / 60.0) * 30.0;
  double kakudo = (double)abs(30 * h + gosa - 6 * m);
  double sita = (kakudo / 180.000) * PI;
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(sita));
  printf("%.15f", ans);
  return 0;
}
