/* ex4_2
  bonbonc */

#include<stdio.h>
#include<math.h>
int main(void){
	int length_hours,length_minutes,hours,minutes;
	double theta_hours,theta_minutes;
	scanf("%d%d%d%d",&length_hours,&length_minutes,&hours,&minutes);
	
	theta_hours = (double)((hours+(double)minutes/60)*(M_PI/6));/*時針の回転角（ラジアン）*/
	theta_minutes = (double)(minutes*(M_PI/30));/*分針の回転角（ラジアン）*/
	
	printf("%.20lf\n",sqrt(pow((double)length_hours,2.0)+pow((double)length_minutes,2.0)-(double)(2*length_hours*length_minutes*cos(theta_hours-theta_minutes))));
	/*余弦定理で時針と分針の先の距離を計算して出力。*/
	return 0;
}