#include<stdio.h>
#include<math.h>
int A,B,H,M,t;
double cos(double x);
double C,CC;
scanf("%d,%d,%d,%d",&A,&B,&H,&M);
t = H * 60 + M
CC = A ** 2 + B **2 - 2*A*B*cos(11 * M_PI * t /360)
printf("%f",CC**(1/2))