#include <iostream>
#include <math.h>
using namespace std;
int main() {
int a,b,h,m;
cin>>a>>b>>h>>m;
double angle1 = abs(0.5 * (h * 60 + m) - 6 * m);
double pi=2*acos(0.0);
double angle=(angle1*pi)/180;
double y=sqrt(a*a+b*b-2*a*b*cos(angle));
printf("%.20lf\n",y);

	return 0;
}