#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double ex = 1e-9;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
double s1, s2, s, ans;
int main() {
  int a, b, h, m;
  scanf("%d%d%d%d", &a, &b, &h, &m);
  s1 = h * 30 + m * 0.5;
  s2 = m * 6;
  s = fabs(s1 - s2);
  if (s > 180) s = 360 - s;
  s = s * acos(-1.0) / 180;
  ans = sqrt(a * a + b * b - 2 * a * b * cos(s));
  printf("%.20lf", ans);
}
