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

int main(){
    int a,b,h,m;

    scanf("%d %d %d %d", &a, &b, &h, &m);

    int x;
    x = abs((h * 60 + m) / 2 - m * 6);
    long double c;
    c = sqrt(a * a + b * b - 2 * a * b * cos(M_PI / 180 * x));
    printf("%.18Lf", c);
    }