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;
            }

            AxisPoint hPt = AxisPoint.FromDegreeAndLength(hKaku, hLen);
            AxisPoint mPt = AxisPoint.FromDegreeAndLength(mKaku, mLen);

            var res = hPt.GetDistance(mPt);
            System.Console.WriteLine(res);
        }

    }

    sealed class AxisPoint {
        public double X { get; }
        public double Y { get; }

        public AxisPoint(double x, double y) {
            this.X = x;
            this.Y = y;
        }

        public static AxisPoint FromDegreeAndLength(double degree, double length) {
            if (length < 0) throw new ArgumentOutOfRangeException(nameof(length));
            if (degree < 0) throw new ArgumentOutOfRangeException(nameof(degree));

            if (360 <= degree) {
                degree = degree % 360;
            }

            if (degree == 0) {
                return new AxisPoint(0, length);
            }
            if (degree == 90) {
                return new AxisPoint(length, 0);
            }
            if (degree == 180) {
                return new AxisPoint(0, length * -1);
            }
            if (degree == 270) {
                return new AxisPoint(length * -1, 0);
            }

            double radian;
            double x;
            double y;
            if (degree < 90) {
                radian = (90 - degree) * Math.PI / 180;
                y = Math.Sin(radian) * length;
                x = Math.Cos(radian) * length;
            }
            else if (degree < 180) {
                radian = (degree - 90) * Math.PI / 180;
                y = Math.Sin(radian) * length * -1;
                x = Math.Cos(radian) * length;
            }
            else if (degree < 270) {
                radian = (270 - degree) * Math.PI / 180;
                y = Math.Sin(radian) * length * -1;
                x = Math.Cos(radian) * length * -1;
            }
            else {
                radian = (degree - 270) * Math.PI / 180;
                y = Math.Sin(radian) * length;
                x = Math.Cos(radian) * length * -1;
            }
            return new AxisPoint(x, y);
        }

        public double GetDistance(AxisPoint to) {
            return Math.Sqrt(Math.Pow(this.X - to.X, 2) + Math.Pow(this.Y - to.Y, 2));
        }

        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            var other = obj as AxisPoint;
            return this.X == other.X && this.Y == other.Y;
        }
        
        public override int GetHashCode()
        {
            return (int)this.X ^ (int)this.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: 28632