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