using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            string[] input = Console.ReadLine().Split(" ");
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int hour = int.Parse(input[2]);
            int minute = int.Parse(input[3]);

            //double theta_A = ((2 * Math.PI / 12) * hour) + ((Math.PI / 360) * minute);
            //double theta_B = ((2 * Math.PI / 60) * minute);
            //double theta = Math.Abs(theta_A - theta_B);
            //if (theta > Math.PI) theta = Math.PI - theta;
            double theta_A = ((2.0 / 12) * hour) + ((1.0 / 360) * minute);
            double theta_B = ((2.0 / 60) * minute);
            double theta = Math.Abs(theta_A - theta_B);
            if (theta > 1.0) theta = 1.0 - theta;


            double distance = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(theta * Math.PI));
            Console.WriteLine(distance);
        }
    }
}