#include<stdio.h>
#include<math.h>
int main(void){
int A,B,H,M,t;
double cos(double x);
double CC;
scanf("%d,%d,%d,%d\n",&A,&B,&H,&M);
    t = H * 60 + M;
    CC = pow(A,2.0) + pow(B,2.0) - 2*A*B*cos(11 * M_PI * t /360);
    printf("%f\n",pow(CC,0.5));
return 0;
}
