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

int main(){
    int A,B,H,M;
    scanf("%d",&A); scanf("%d",&B);
    scanf("%d",&H); scanf("%d",&M);
    double lx,ly,sx,sy;
    double theta;
    //時針の方の端点の座標
    theta = (H*30 + 0.5*M)*M_PI/180;
    lx = A*sin(theta);
    ly = A*cos(theta);
    //printf("theta=%f lx=%f ly=%f\n",theta,lx,ly);
    //分針の方の端点の座標
    theta = M*6*M_PI/180;
    sx = B*sin(theta);
    sy = B*cos(theta);

    printf("%.9f\n",sqrt((lx-sx)*(lx-sx)+(ly-sy)*(ly-sy)));
    //printf("theta=%f sx=%f sy=%f\n",theta,sx,sy);
    
    return 0;
}