/* ex4_2
   offNaria */
#include <stdio.h>
#include <math.h>

double cosFormula(double a, double b, double c);

int main(void){
  double lengthOfMinuteHand, lengthOfHourHand, hour, minute;
  scanf("%d %d %d %d", &lengthOfMinuteHand, &lengthOfHourHand, &hour, &minute);
  double angle = 30 * hour + minute / 2 - 6 * minute; //時針は60分で30度＝1分で0.5度，分針は1分で6度動く
  angle = angle * M_PI / 180; //ラジアンに変換
  printf("%.11lf\n", cosFormula(lengthOfMinuteHand, lengthOfHourHand, angle)); //余弦定理
  return 0;
}

double cosFormula(double a, double b, double c){
  return sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c)); //余弦定理
}
