/*  ex4_2
    person_A  */
#include<stdio.h>
#include<math.h>

int main(void){
    const double pi=3.14159265359;
    double lengthA,lengthB,angleA_B;
    int hours,minutes;
    //lengthA,lengthB,hours,minutesの値の入力
    scanf("%lf%lf%d%d",&lengthA,&lengthB,&hours,&minutes);
    //以下時針と分針の間の角度を取得
    angleA_B=((double)((11*(hours*60+minutes))%720)/360)*pi;
    //余弦定理を逆算して答えの出力
    printf("%.10f\n",sqrt(lengthA*lengthA+lengthB*lengthB-2*lengthA*lengthB*cos(angleA_B)));
    return 0;
}