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

#define pai 3.14159265

int main(void){

    int a, b, h, m, hd;
    double md, ans, x;
    scanf("%d%d%d%d",&a,&b,&h,&m);

    hd = 6 * m;
    md = 0.5 * m + 30.0 * h;
    x = (hd-md) * pai / 180;

    ans = a*a+b*b-2*a*b*cos(x);
    printf("%f",sqrt(ans));

    return 0;
}