#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  long long t = 1;
  while (t--) {
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    h += m / 60;
    h *= 30;
    m *= 6;
    long double theta = abs(m - h);
    long double sx = (a * a + b * b) - (2 * a * b * cos(pi * (theta / 180)));
    cout << fixed << setprecision(11) << sqrt(sx);
  }
  return 0;
}
