#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  float H, M;
  cin >> A >> B >> H >> M;
  double pi = 2.0 * asin(1.0);
  double h_a = 360 * (H + M / 60) / 12;
  double m_a = 360 * (M / 60);
  double angle = max(h_a, m_a) - min(h_a, m_a);
  if (angle > 180) h_a = 360 - h_a;
  double unit = pi / 180.0;
  double len = A * A + B * B - 2 * A * B * cos(angle * unit);
  cout << setprecision(11) << sqrt(len) << endl;
}
