#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main(){

 long long int A,B,H,M;
  scanf("%lld %lld %lld %lld",&A,&B,&H,&M);

/*
  char A[];
  scanf("%s",A);
  */

  /*
  long long int A[N+1];
  long long int i;
  for(i=1;i<=N;i++){
   scanf("%lld",&A[i]);
   }
  */
  int min;
  double lrad,srad,rad;
  double ans;
  min = (double)(H)*60.0 + (double)(M);
  
  lrad = (360.0/(12.0*60.0))*(double)(min);
  srad = (360.0/60.0)*(double)(M);
 
  rad = lrad - srad;
  double a,b;
  a = (double)(A);
  b = (double)(B);

  ans = sqrt(a*a+b*b-2*a*b*cos(((rad)/360)*2*3.141592653589));

  printf("%10.10lf\n",ans);


  







 return(0);
 }
