#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
double max(double a, double b) { return a > b ? a : b; }
int main(){
    double a,b,h,m,theta,ans;
    int i,j;
    const double pai=3.1415926535898;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    theta=(60*h-11*m)/360*pai;
    ans=sqrt(a*a+b*b-2*a*b*cos(theta));
    printf("%.11lf\n",ans);
    return 0;
}