#include <iostream>
#include <cstdlib>
#include <cmath>
#include <math.h> 
using namespace std;
int main() {
long double A,B,H,M;
long double pi = 3.14159265358979323846264338327950288419;
long double HS,MS,S,L;
  cin>>A>>B>>H>>M;
 HS=0.5*(H*60+M);
 MS=6*M;
 S=HS-MS;
 S=abs(S);
 if(S>180){S-=180;}
  S=cos(S*(pi/180));
 L=sqrtf((A*A)+(B*B)-(2*A*B*S));
cout<<L;
}