#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    long double rad=PI*2*((long double)h/12.0+((long double)m/60.0)-(long double)m/60);
    long double c=(long double)(a*a+b*b)-2*a*b*cos(rad);
    printf("%20.20Lf",sqrtl(c));
    return 0;
}