using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int A = int.Parse(input[0]);
			int B = int.Parse(input[1]);
			int H = int.Parse(input[2]);
			int M = int.Parse(input[3]);
		 double answer;
			var angle = (60 * H + M) * 5.5f;
			var cos = Math.Cos(angle * (Math.PI / 180));
			answer=A*A+B*B-2*A*B*cos;
			Console.WriteLine(System.Math.Sqrt(answer));

	

		}
	}

}

	