#include<bits/stdc++.h>
using namespace std;

int main()
{
    
    double a, b, h, m;
    double arg, ans;
    cin >> a >> b >> h >> m;
    arg = (h*60-11*m)/360;
  	ans = sqrt(a*a+b*b - 2*a*b*cos(arg*3.14159265358979));
	printf("%12.12lf\n", ans);
}