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

int main(){
    float a = 0.0,b = 0.0,h = 0.0,m = 0.0,ans=0.0,tmp=0.0,pi=0.0;
    scanf("%f%f%f%f",&a,&b,&h,&m);
    pi=fabs(((11*m-60*h)*PI)/360);
    ans=sqrt(a*a+b*b-2*a*b*cos(pi));
    printf("%.10f",ans);
    return 0;
}

