#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long int MAX = 9187201950435737471;
const int N = 1000006;
const long long int INF = -1e12;
const long double PI = acos(-1);
void solve(int T) {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double c = PI * 2.0 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
  long double ans = a * a + b * b - 2.0 * a * b * (long double)cos(c);
  cout << fixed << setprecision(12) << sqrt(ans);
}
int main() {
  int T = 1;
  for (int i = 1; i <= T; i++) {
    solve(i);
  }
  return 0;
}
