import 'dart:io';
import 'dart:math';

void main(List<String> args) {
  final ABHM = stdin
      .readLineSync()
      .split(' ')
      .map(
        (x) => int.parse(x),
      )
      .toList();
  final A = ABHM[0];
  final B = ABHM[1];
  final H = ABHM[2];
  final M = ABHM[3];
  final Hx = 360 / 12 * H;
  final Mx = 360 / 60 * M;
  final angle = (Hx - Mx).abs();
  final ans = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(angle * pi / 180));
  print(ans);
}
