#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long pow(long long x, long long n, long long m) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return pow(x * x % m, n / 2, m);
  else
    return x * pow(x, n - 1, m) % m;
}
long long pow(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (x == 1)
    return (1);
  else if (n % 2 == 0)
    return pow(x * x, (n / 2));
  else
    return x * pow(x, n - 1);
}
int ketasuu(long long h) {
  if (h < 0)
    return (-(ketasuu(-h)));
  else if (h < 10)
    return (1);
  else
    return (1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % 998244353;
    inv[i] = 998244353 - inv[998244353 % i] * (998244353 / i) % 998244353;
    finv[i] = finv[i - 1] * inv[i] % 998244353;
  }
}
long long com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 998244353) % 998244353;
}
int main() {
  long double a, b;
  cin >> a >> b;
  long double h, m;
  cin >> h >> m;
  long double tyousinn = 6 * m;
  long double tannsinn = ((h * 30) + (m / 2));
  long double kakudo = abs(tyousinn - tannsinn);
  kakudo = (kakudo / 180) * 3.1415926535897932384626433832795028841971693993;
  kakudo = min(kakudo, 360 - kakudo);
  long double kotae = sqrt((a * a) + (b * b) - 2 * a * b * (cos(kakudo)));
  cout << fixed << setprecision(10) << kotae << endl;
}
