#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x;
  if (y == 0) return 1;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
void solve() {
  long long int a, b;
  double h, m, c = 0.000000;
  double t;
  cin >> a >> b >> h >> m;
  double x1 = h * 30 + m * .5;
  double x2 = m * 6;
  t = fabs(x1 - x2);
  if (t > 180) {
    t = 360 - t;
  }
  c = sqrt(a * a + b * b - 2 * a * b * cos(t * acos(-1) / 180));
  printf("%.20lf\n", c);
  return;
}
int main() { solve(); }
