#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(void){
    int a,b,h,m,k;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    k = 30*h+m*6/12-m*6;
    if(k>180) k=360-k;
    printf("%.10lf",sqrt(a*a+b*b-2*a*b*cos(PI/180*k)));
}