#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD 1000000007
#define INF 2000000000
#define PI 3.14159265
#define ull unsigned long long

int main(){
    double a = 0.0,b = 0.0,h = 0.0,m = 0.0,ans=0,tmp=0,pi=0;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    pi=(PI*(m-5*h))/30;
    tmp=a*a+b*b-2*a*b*cos(pi);
    ans=sqrt(tmp);
    printf("%lf",ans);
    return 0;
}

