#include <bits/stdc++.h>
using namespace std;
struct vec2 {
  double height = 0;
  double width = 0;
};
int main() {
  static const double pi = 3.141592653589793;
  int alen, blen;
  int min, hou;
  vec2 aver, bver;
  cin >> alen >> blen >> hou >> min;
  if (hou == 0 && min == 0) {
    aver.height = (double)alen;
    aver.width = (double)0;
  } else {
    aver.height = (double)alen *
                  cos(pi * (((double)hou + ((double)min / 60)) / (double)6));
    aver.width = (double)alen *
                 sin(pi * (((double)hou + ((double)min / 60)) / (double)6));
  }
  if (min == 0) {
    bver.height = (double)blen;
    bver.width = (double)0;
  } else {
    bver.height = (double)blen * cos(pi * ((double)min / (double)30));
    bver.width = (double)blen * sin(pi * ((double)min / (double)30));
  }
  cout << sqrt(pow(aver.height - bver.height, 2) +
               pow(aver.width - bver.width, 2));
}
