using System;


namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            double PI = 3.14159265358979323846264338327950;
            string x = Console.ReadLine();
            //y[]はchar
            //切り分け
            string[] y = x.Split();
            //int型に直す
            int a = int.Parse(y[0]);
            int b = int.Parse(y[1]);
            int h = int.Parse(y[2]);
            int m = int.Parse(y[3]);

            double hh, mm;
            double kakudo;
            double rad;
            double c, cc;

            hh = 30 * h + m / 2;
            mm = 6 * m;

            if (Math.Abs(hh - mm) >= 180)
            {
                kakudo = 360 - Math.Abs(hh - mm);
            }
            else {
                kakudo = Math.Abs(hh - mm);
            }
            rad = kakudo * PI / 180;

            //Console.WriteLine(kakudo);
            //Console.WriteLine(rad);

            cc = b * b + a * a - 2 * a * b * Math.Cos(rad);
            c = Math.Sqrt(cc);

            string text = c.ToString("F20");
            Console.WriteLine(text);
        }
    }
}