import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	}

} Main public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	} main {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	} Scanner scn=new Scanner(System.in); scn new Scanner(System.in) int lenHour=scn.nextInt() lenHour scn.nextInt() scn.nextInt scn lenMin=scn.nextInt(); lenMin scn.nextInt() scn.nextInt scn double hour=scn.nextDouble()/6*Math.PI hour scn.nextDouble()/6*Math.PI scn.nextDouble()/6 scn.nextDouble() scn.nextDouble scn 6 Math.PI Math Math.PI min=scn.nextDouble()/30*Math.PI; min scn.nextDouble()/30*Math.PI scn.nextDouble()/30 scn.nextDouble() scn.nextDouble scn 30 Math.PI Math Math.PI hour+=min/12 hour min/12 min 12 System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour))) System.out.println System.out System System.out Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)) Math.sqrt Math lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour) lenHour*lenHour+lenMin*lenMin lenHour*lenHour lenHour lenHour lenMin*lenMin lenMin lenMin 2*lenMin*lenHour*Math.cos(min-hour) lenHour 2*lenMin*lenHour*Math.cos(min-hour) 2 lenMin lenHour Math.cos(min-hour) Math.cos Math min-hour min hour String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int lenHour=scn.nextInt(),
			lenMin=scn.nextInt();
		double hour=scn.nextDouble()/6*Math.PI,
			   min=scn.nextDouble()/30*Math.PI;
		
		hour+=min/12;
		
		System.out.println(Math.sqrt(lenHour*lenHour+lenMin*lenMin-2*lenMin*lenHour*Math.cos(min-hour)));
	}

}
