import 'dart:io';

import 'dart:math' as math;

void main(List<String> arguments) {
  final abhm =
      stdin.readLineSync().split(' ').map((raw) => int.parse(raw)).toList();
  final a = abhm[0];
  final b = abhm[1];
  final h = abhm[2];
  final m = abhm[3];
  final hTheta = (60 * h + m) / 720 * 2 * math.pi;
  final mTheta = m / 60 * 2 * math.pi;
  final aX = a * math.cos(hTheta);
  final ay = a * math.sin(hTheta);
  final bX = b * math.cos(mTheta);
  final by = b * math.sin(mTheta);
  final dx = aX - bX;
  final dy = ay - by;

  print(math.sqrt(math.pow(dx, 2) + math.pow(dy, 2)));
}
