#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _USE_MATH_DEFINES


int main() {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  
  double pi =3.14159265359;
  
  double C;
  C = 2*pi/12;
  double D;
  D = 2*pi/60;
    
  double S;
  S=(A*A+B*B-2*A*B*cos((H*C+M*D/12)-M*D));
  
  cout << sqrtl(long double S) <<endl;
  
}
