#include <bits/stdc++.h>
using namespace std;
int main() {
  int hour, minute, hand_hour, hand_minute;
  double angle = 0;
  cin >> hand_hour >> hand_minute >> hour >> minute;
  minute = minute + 60 * hour;
  angle = minute * 11.0 * atan(1.0) / 90.0;
  printf("%.10f\n", sqrt(hand_hour * hand_hour + hand_minute * hand_minute -
                         2.0 * hand_hour * hand_minute * cos(angle)));
  return 0;
}
