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

int A,B,H,M;

signed main() {
  cin >> A >> B >> H >> M;
  double t = M_PI * (60*H - 11*M) /30 /12;
  if(t > M_PI) t = 2*M_PI - t;
  double cc = (double)(A*A + B*B) - 2.0*A*B * cos(t);
  printf("%.10f\n", sqrt(cc));
}
