#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int t = 1;
  while (t--) {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double rad = 2 * 3.14159265358979323846264338327950L *
                      ((h / 12.0 + (m / 60.0) / 12.0) - (m / 60.0));
    long double ans = ((a * a) + (b * b) - (2 * a * b * cos(rad)));
    cout << fixed << setprecision(20) << (long double)sqrt(ans) << endl;
  }
}
