#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define pai 3.1415926535897932384626433832795028841971693
#define ll long long
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
double fmod(double x, double y);

int main(){
  long double a,b,h,m,k;
  long double ans,deg,rad;
  scanf("%llf %llf %llf %llf",&a,&b,&h,&m);
  deg=5.5*(m+60*h);
  k=fmod(rad,360);
  rad = deg*(pai/180);
  ans=sqrt(a*a+b*b-2*a*b*cos(rad));

  printf("%.20Lf",ans);
  return 0;
}