#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589L

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  (long double)A;
  (long double)B;
  long double w1 = (PI/30)*((long double)H*60+(long double)M);
  long double w2 = (PI/360)*((long double)H*60+(long double)M);
  long double x;
  x = A*A + B*B -2*A*B*cos(w1-w2);
  long double y = sqrt(x);
 #include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  (long double)A;
  (long double)B;
  long double w1 = (PI/30)*((long double)H*60+(long double)M);
  long double w2 = (PI/360)*((long double)H*60+(long double)M);
  long double x;
  x = A*A + B*B -2*A*B*cos(w1-w2);
  long double y = sqrt(x);
 printf("%20.20%lf",y)
  return 0;
}

  return 0;
}
