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

int main()
{
    int len_h = 0 ;
    int len_m = 0 ;
    int tim_h = 0 ;
    int tim_m = 0 ;
    
    double deg_h = 0.0 ;
    double deg_m = 0.0 ;
    double deg_b = 0.0 ;
    
    double rad_b = 0.0 ;
    
    double sq_b  = 0.0 ;
    
    double len_b = 0.0 ;
    
    scanf("%d %d %d %d", &len_h, &len_m, &tim_h, &tim_m);
    
    deg_h = 360.0 * ((double)tim_h*60.0 + (double)tim_m)/720.0 ;
    deg_m = 360.0 * (double)tim_m/60.0 ;
    deg_b = abs(deg_h - deg_m) ;
    
    if (deg_b > 180.0) deg_b = 360.0 - deg_b ;
    
    rad_b = M_PI* deg_b / 180.0 ;
    
    sq_b = len_h*len_h + len_m*len_m - 2* cos(rad_b) *len_h*len_m ;
    
    len_b = sqrt(sq_b);
    
    
    printf("%.10f\n",len_b);

    return 0;
}