#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int unused __attribute__((unused));
  int A, B, H, M;
  long double totalmin, Aangle, Bangle, a[2], b[2];
  unused = scanf("%d %d %d %d", &A, &B, &H, &M);

  totalmin = H*60 + M;
  Aangle = 2*M_PI - (totalmin*2*M_PI/720 - M_PI/2);
  Bangle = 2*M_PI - (M*2*M_PI/60 - M_PI/2);
  //printf("Aangle:%f, Bangle:%f\n", Aangle, Bangle);
  a[0] = A*cos(Aangle);
  a[1] = A*sin(Aangle);
  b[0] = B*cos(Bangle);
  b[1] = B*sin(Bangle);
  //printf("%f %f %f %f ", a[0], a[1], b[0], b[1]);
  printf("%f", sqrt(fabsl((a[1]-a[0])*(a[1]-a[0]) + (b[1]-b[0])*(b[1]-b[0]))));
  return 0;
}