#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
LL max(LL a, LL b){
  if (a > b) {
    return a;
  }else return b;
}

int main(void)
{
  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double the1=((double)h*60+(double)m)/2;
  double the2=(double)m*6;
  double the=ABS(the1-the2);
  if (the > 180.0) {
    the = 360.0 - the;
  }

  //printf("%lf\n" ,the );
  double a2 = (double)a * (double)a;
  double b2 = (double)b * (double)b;
  the = the * M_PI /180;
  //printf("%lf\n", cos(the));
  double c = sqrt(a2+b2 - 2 * (double)a * (double)b *cos(the));
  printf("%.15lf\n", c);
  return 0;
}
