#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define pai 3.14159265358979323846

int main(void) {
  int scan; // scanf result
  long double answer; // to output 
  long double a; // to input 
  long double b; // to input 
  long double h; // to input 
  long double m; // to input 

  scan = scanf("%Lf", &a);
  scan = scanf("%Lf", &b);
  scan = scanf("%Lf", &h);
  scan = scanf("%Lf", &m);

  long double k;
  long double diff;
  diff = (h + m / 60) * 30 - m * 6;
  if (diff == 0) {
    k = 0;
  } else {
    k = diff;
  }

  if (k >= 180) {
    k = k - 180;
  } else if (k <= -180) {
    k = (-1) * k - 180;
  } else if (k < 0) {
    k = (-1) * k;
  }

  long double rad;
  rad = k * (pai / 180);

  answer = a * a + b * b - 2 * a * b * cos(rad);
  answer = sqrt(answer);
  printf("%.16Lf", answer);
  return (0);
}
