#include<iostream>
#include<math.h>
using namespace std;
int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	printf("%.13lf\n",sqrt(a*a+b*b-2*a*b*cos(((h+m/60)*30-m*6)*3.14159265358979323/180)));
	return 0;
}