#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld PI = 3.14159265358979323846264338327950L;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc = 1;
  while (tc--) {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    ld ah = (ld)(h + (ld)m / 60.0) / 12.0;
    ld am = (ld)m / 60.0;
    ld theta = 2 * PI * abs(ah - am);
    ld cos_theta = cos(theta);
    ld res = sqrt(a * a + b * b - 2 * a * b * cos_theta);
    cout << res << endl;
  }
  return 0;
}
