/* ex4_2 C-:
    dada__  */
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979

int main(void){
    int hour_length, min_length, hour, min;
    double rad, distance;

    scanf("%d %d %d %d", &hour_length, &min_length, &hour, &min);

    rad = (min*PI/30)-((hour*60+min)*PI/360); //時針と分針の成す角

    //余弦定理による端点間の距離の算出
    distance = sqrt((double) (pow(hour_length,2) + pow(min_length,2) - 2*hour_length*min_length*cos(rad)));
    printf("%.9f\n", distance);

    return 0;
}