/* ex4_1
   YSK722 */

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

int main(void){
    double short_hand, long_hand, hour, minute, ans;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
    /* 余弦定理を用いる
       cos(-x) = cos(x)より、回転角の大小は考えない */
    ans = sqrt(
              pow(short_hand, 2) + pow(long_hand, 2) \
              - 2 * short_hand * long_hand * cos(M_PI*(hour/6.0 - minute/30.0))
          );
    printf("%lf", ans);
    return 0;
}