import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
} import java.io.*; io.* java import java.math.*; math.* java import java.util.*; util.* java public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
} Main public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	} main { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) double HourLength = input.nextDouble(); HourLength input.nextDouble() input.nextDouble input double MinLength = input.nextDouble(); MinLength input.nextDouble() input.nextDouble input double H = input.nextDouble(); H input.nextDouble() input.nextDouble input double M = input.nextDouble(); M input.nextDouble() input.nextDouble input double Htheta = (H/12)*360.0; Htheta (H/12)*360.0 (H/12) H 12 360.0 double Mtheta = (M/60)*360.0; Mtheta (M/60)*360.0 (M/60) M 60 360.0 Htheta+=30.0*(Mtheta/360.0) Htheta 30.0*(Mtheta/360.0) 30.0 (Mtheta/360.0) Mtheta 360.0 double ans = HourLength*HourLength+MinLength*MinLength; ans HourLength*HourLength+MinLength*MinLength HourLength*HourLength HourLength HourLength MinLength*MinLength MinLength MinLength double TotalAngle = Math.abs(Htheta-Mtheta); TotalAngle Math.abs(Htheta-Mtheta) Math.abs Math Htheta-Mtheta Htheta Mtheta double cos = Math.cos(Math.toRadians(TotalAngle)); cos Math.cos(Math.toRadians(TotalAngle)) Math.cos Math Math.toRadians(TotalAngle) Math.toRadians Math TotalAngle ans-=2*HourLength*MinLength*cos ans 2*HourLength*MinLength*cos MinLength 2*HourLength*MinLength*cos 2 HourLength MinLength cos System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
} public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
} Main
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		double HourLength = input.nextDouble();
		double MinLength = input.nextDouble();
		double H = input.nextDouble();
		double M = input.nextDouble();
		double Htheta = (H/12)*360.0;
		double Mtheta = (M/60)*360.0;
		Htheta+=30.0*(Mtheta/360.0);
		double ans = HourLength*HourLength+MinLength*MinLength;
		double TotalAngle = Math.abs(Htheta-Mtheta);
		double cos = Math.cos(Math.toRadians(TotalAngle));
		ans-=2*HourLength*MinLength*cos;
		//System.out.println(cos);
		System.out.println(Math.sqrt(ans));
	}
}
