using System;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        int A = int.Parse(inp[0]);
        int B = int.Parse(inp[1]);
        int H = int.Parse(inp[2]);
        int M = int.Parse(inp[3]);
 
        int angle = Math.Abs(((H+M/12) * 30) - M * 6);
        int f_angle = angle <= 180 ? angle : 360 - angle;
        double C = 0;
        C = Math.Sqrt(A * A + B * B - 2 * A * B * Math.Cos(f_angle * Math.PI / 180.0));
 
        //Console.WriteLine(f_angle);
        //Console.WriteLine(Math.Cos(f_angle * Math.PI / 180.0));
        Console.WriteLine(C);
    }
}