#include <bits/stdc++.h>
using namespace std;
#include <math.h>  /* M_PI */
#include <stdio.h> /* printf */
int main(void)
{
 int a,b,h,m;
  cin >>a >>b >>h >>m;
  long double X,Y;
  X=2*M_PI/60*m;
  Y=2*M_PI/720*(60*h+m);
  long double C;
  long double Z;
  if(X-Y>=0){
    if(X-Y>=M_PI){
      Z=2*M_PI-X+Y;
    }
    else{
    Z=X-Y;
    }
  }
  else{
    if(Y-X>=M_PI){
      Z=2*M_PI-Y+X;
    }
    else{
    Z=Y-X;
    }
  }
  if(X-Y!=0){
    if(Z==M_PI){
      cout <<a+b;
    }
    else{
  C=a*a+b*b-2*a*b*cos(Z);
  long double D;
  D=sqrt(C);
 cout <<fixed <<setprecision(10)<<D<<endl;
    }
  }
  else{
    cout <<|a-b|;
  }
}