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


int main(){
    double pai=3.14159265358;
    int A,B,H,M;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    double Aw,Bw,Ar,Br;
    Aw=(2*pai)/(12*60);
    Bw=(2*pai)/60;
    Ar=Aw*((H*60)+M);
    Br=Bw*M;
    double C;
    C=pow(A,2)+pow(B,2)-2*A*B*cos(Ar-Br);
    C=pow(C,0.5);
    printf("%.9f\n",C);
    return 0;
}