/*
 * ex 4_2
 * kamecha
 */
#include<stdio.h>
#include<math.h>

int main(void){
    double h_hand, m_hand, hour, minute;
    scanf("%lf %lf %lf %lf", &h_hand, &m_hand, &hour, &minute);
    double time = 60*hour + minute;
    //角速度の差を出しておく
    double theta = time*M_PI*11/360;
    //余弦定理
    double ans = sqrt(h_hand*h_hand + m_hand*m_hand - 2*h_hand*m_hand*cos(theta));
    printf("%.10lf\n", ans);
}
