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

int main(){
        int a, b, h, m;
        double ang, len;
        scanf("%d %d %d %d", &a, &b, &h, &m);

        ang=(double)(h*60+6)/720-m*6;

        len=(double)(a*a+b*b-2*b*a*cos(ang));

        len=sqrt(len);

        printf("%lf", len);

        return 0;
}

