#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  h = h * 60 + m;
  long double ha = (h % 720) / 2.0, ma = (h % 60) * 6.0;
  long double dif = abs(ha - ma);
  dif = min(dif, 360.0 - dif);
  dif *= acos(-1) / 180.0;
  long double c = (long double)a * (long double)a +
                  (long double)b * (long double)b -
                  2 * (long double)a * (long double)b * cos(dif);
  cout << setprecision(20) << sqrt(c) << endl;
}
