/*  ex4_2
    yy8332  */

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


int main(void){
  double lengthA, lengthB, hour, minute, theta, ans;

  //入力読み取り
  scanf("%lf %lf %lf %lf", &lengthA, &lengthB, &hour, &minute);

  //角度計算
  theta = (((hour + minute / 60) * 30 - minute * 6) / 180) * M_PI;

  //長さ計算
  ans = pow(lengthA, 2.0) + pow(lengthB, 2.0) - 2 * lengthA * lengthB * cos(theta);

  ans = sqrt(ans);


  //出力
  printf("%.10f",ans);


  return 0;
}
