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

int main(void){
    int a,b,h,m;
    double h_num, m_num, arg, rad, ans;
    scanf("%d %d %d %d", &a, &b, &h, &m);
    h_num = h/12.0 * 360;
    m_num = m/60.0 * 360;
    h_num += m/60.0 * 30;
    // printf("h : %f\n m : %f\n", h_num, m_num);
    arg = fabs(h_num - m_num);
    if(arg >= 180) arg -= 180.0;
    // printf("arg : %f\n", arg);
    rad = arg/180.0 * 3.141592653589793238462643;
    // printf("rad = %f\n", sin(rad));
    ans = sqrt((a*sin(rad))*(a*sin(rad)) + (b - a*cos(rad))*(b - a*cos(rad)));
    printf("%.20f", ans);
}
