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

int main(void)
{
    int a,b,h,m;
    double alpha,beta,ans;

    scanf("%d %d %d %d",&a,&b,&h,&m);

    alpha=(h+m/60.0)*M_PI/6.0;
    beta=m*M_PI/30.0;

    ans=a*a+b*b-2*a*b*cos(alpha-beta);
    ans=sqrt(ans);

    printf("%15.11f",ans);

    return 0;
}