#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int a,b;
    double h,m,deg;
    scanf("%d %d %lf %lf",&a,&b,&h,&m);
    deg=2*3.14159265*(h/12+m/60/12-m/60);
    printf("%f",sqrt(a*a+b*b-2*a*b*cos(deg)));
}
