#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include <iomanip>
int main(){
  int a,b,h,m;
  std::cin>>a>>b>>h>>m;
  std::cout<<std::fixed<<std::setprecision(10)<<std::sqrt(a*a+b*b-2*a*b*std::cos(M_PI*(60*h-11*m)/360))<<std::endl;
}