/*  ex4_2
    potter0723sw  */

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
    double lengtha,lengthb,hour,minute,radian,mid,ans;
    scanf("%lf %lf %lf %lf", &lengtha, &lengthb, &hour, &minute);
    radian = fabs(5.5 * minute - 30 * hour) * M_PI / 180;//5.5は6-0.5で長針の1分6度の動きから短針の1分0.5度の動きの差をとったもの
    mid = pow(lengtha,2)+ pow(lengthb,2) - 2*lengtha*lengthb * cos(radian);//余弦定理
    ans = sqrt(mid);//平方根をとって答え
    printf("%15.10lf\n", ans);
    return 0;
}