#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main(void){
    int A,B,H,M;
    long double rad,ans;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    
    rad = ((((long double)H + ((long double)M/60))/12)-((long double)M/60))*2*PI;
   
    ans = sqrtl((long double)(A*A + B*B) -(long double)(2*A*B)*cosl(rad));
    printf("%20.20Lf\n",ans);

    return 0;
}