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

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double ra=30*H+0.5*M-6*M;
  double c = cos(ra*M_PI/180);
  double ans = pow(A,2.0)+pow(B,2.0)-2.0*A*B*c;
  printf("%.10lf\n", sqrt(ans));
  return 0;
}
