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

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = IOUtils.ReadInts();
            var hLen = vals[0];
            var mLen = vals[1];
            var hour = vals[2];
            var min = vals[3];

            var totalMin = hour * 60 + min;

            var hKakuPerMin = 0.5;
            var mKakuPerMin = 6;

            var hKaku = totalMin * hKakuPerMin;
            var mKaku = totalMin * mKakuPerMin % 360;

            if (hKaku == mKaku) {
                System.Console.WriteLine(Math.Abs(hLen - mLen));
                return;
            }
            if (Math.Abs(hKaku - mKaku) == 180) {
                System.Console.WriteLine(hLen + mLen);
                return;
            }

            Point hPt = GetPoint(hLen, hKaku);
            Point mPt = GetPoint(mLen, mKaku);

            var res = Math.Sqrt(Math.Pow(hPt.x - mPt.x, 2) + Math.Pow(hPt.y - mPt.y, 2));
            System.Console.WriteLine(res);
            
        }

        private static Point GetPoint(int len, double kaku) {
            if (kaku == 0) {
                return new Point(0, len);
            }
            if (kaku == 90) {
                return new Point(len, 0);
            }
            if (kaku == 180) {
                return new Point(0, len * -1);
            }
            if (kaku == 270) {
                return new Point(len * -1, 0);
            }



            if (0 < kaku && kaku < 90) {
                // var tmpKaku = kaku * Math.PI / 180;
                // var y = Math.Cos(kaku) * len;
                // var x = Math.Sin(kaku) * len;

                var tmpKaku = (90 - kaku) * Math.PI / 180;
                var y = Math.Sin(tmpKaku) * len;
                var x = Math.Cos(tmpKaku) * len;
                return new Point(x, y);
            }
            else if (90 < kaku && kaku < 180) {
                var tmpKaku = (kaku - 90) * Math.PI / 180;
                var y = Math.Sin(tmpKaku) * len * -1;
                var x = Math.Cos(tmpKaku) * len;
                return new Point(x, y);
            }
            else if (180 < kaku && kaku < 270) {
                // var tmpKaku = (kaku - 180) * Math.PI / 180;
                // var y = Math.Cos(tmpKaku) * len * -1;
                // var x = Math.Sin(tmpKaku) * len * -1;
                var tmpKaku = (270 - kaku) * Math.PI / 180;
                var y = Math.Sin(tmpKaku) * len * -1;
                var x = Math.Cos(tmpKaku) * len * -1;
                return new Point(x, y);
            }
            else {
                // var tmpKaku = (kaku - 270) * Math.PI / 180;
                // var y = Math.Sin(tmpKaku) * len;
                // var x = Math.Cos(tmpKaku) * len * -1;
                var tmpKaku = (kaku - 270) * Math.PI / 180;
                var y = Math.Sin(tmpKaku) * len;
                var x = Math.Cos(tmpKaku) * len * -1;
                return new Point(x, y);
            }
        }

        class Point {
            public readonly double x;
            public readonly double y;
            public Point(double x, double y) {
                this.x = x;
                this.y = y;
            }
        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 28692