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

int max(int a,int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){

  int a,b;
  int h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);

  double angle = abs( ((double)h + (double)m/60) * 30 - (double)m * 6 );
  double rad;
  if((int)angle == 180){
    printf("%.10f",a+b);
    return 0;
  }else if(angle > 180){
    rad = -(angle * M_PI/180);
  }else{
    rad = (angle * M_PI/180);
  }

  //printf("%.10f ",h);
  double ans = a * a + b * b -2 * a * b * cos(rad);
  printf("%.10f",pow(ans,0.5));

  return 0;
}