#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef long double ld;
const ld eps = 1.0e-16; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

ld	mto2pi(int m)
{
  	return 3.141592653589793238L * m / 30;
}

ld	hto2pi(int h, int m)
{
	return 3.141592653589793238L * (h * 30 + m / 2) / 180;
}

int main(void)
{
  	int a;
  	int b;
  	int h;
  	int m;
  	ld	t;
  	ld	l;
  	ld  aa;
  	ld  bb;
  	    
  	scanf("%d %d %d %d", &a, &b, &h, &m);
  
    aa = (long double)a;
    bb = (long double)b;
    
	t = hto2pi(h, m) - mto2pi(m);
  
    l = mysqrtl(aa * aa + bb * bb - 2.0L * aa * bb * cos(t));
  	printf("%25.20Lf", l);
  
  	return (0);
}

