using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC168
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_C();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var n = Ex.Read;

            int i = n.LastOrDefault() - '0';
            if (i == 2 || i == 4 || i == 5 || i == 7 || i == 9) "hon".Cw();
            else if (i == 3) "bon".Cw();
            else "pon".Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var k = Ex.ReadInt;
            var s = Ex.Read;

            if (s.Length <= k) s.Cw();
            else
            {
                (string.Join("", s.Take(k)) + "...").Cw();
            }
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
            var l = Ex.ReadIntArray();
            var a = l[0];
            var b = l[1];
            var h = l[2];
            var m = l[3];

            double sh = 30 * h + m * .5;
            double lo = m * 6;
            var d = Math.Abs(sh - lo);
            //$"{sh} {lo} {d} {Math.Cos(d)}".Cw();
            d = Math.Min(360 - d, d);
            //$"{sh} {lo} {d} {Math.Cos(d)}".Cw();
            var c = a * a + b * b - 2 * a * b * Math.Cos(d * Math.PI / 180.0);
            //var c = a * a + b * b - 2 * a * b * Math.Abs(Math.Cos(d));
            //if (d % 90 == 0) c = a * a + b * b - 2 * a * b * Math.Abs(Math.Ceiling(Math.Cos(d)));
            //c.Cw();
            Math.Sqrt(c).Cw();
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 19852