#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  float A, B, H, M;
  cin >> A >> B >> H >> M;
  float rad = PI * 2 * ((H / 12 - M / 60) + M / 60 / 12);

  float ans = A * A + B * B - 2 * A * B * cos(rad);

  cout << sqrt(ans) << endl;
}
return 0;
}
