#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    double a,b,h,m,ans;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    ans=sqrt((b*b)+(a*a)-2*b*a*cos((h*60-11*m)*3.14159265358979/360));
    printf("%lf",ans);
}