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

int main()
{
  int a, b, h, m;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &h);
  scanf("%d", &m);
  double hk = h*30+m*0.5;
  int mk = m*6;
  double rad = (hk - mk)*M_PI/180;
  double da = a*a;
  double db = b*b;
  double l = sqrt(da+db-2*a*b*cos(rad));
  printf("%f\n", l);
  // printf("Hello World!\n");
  return 0;
}