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

int main(void){
    double a,b;
    int h,m;
    scanf("%lf %lf %d %d",&a,&b,&h,&m);
    
    double ax,ay,bx,by;
    double M_PI=3.14159265358979323846;

    ax=cos(M_PI*h/6+M_PI*m/360);
    ay=sin(M_PI*h/6+M_PI*m/360);
    bx=cos(M_PI*m/30);
    by=sin(M_PI*m/30);
    
    //printf("%lf %lf %lf %lf\n",ax,ay,bx,by);
    double ans = (a*ax-b*bx)*(a*ax-b*bx)+(a*ay-b*by)*(a*ay-b*by);
    printf("%.20lf",sqrt(ans));
   
    return 0;
}
