#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338

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

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

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