import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
} Main public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	} main {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) double A = keyboard.nextDouble(); A keyboard.nextDouble() keyboard.nextDouble keyboard double B = keyboard.nextDouble(); B keyboard.nextDouble() keyboard.nextDouble keyboard int H = keyboard.nextInt(); H keyboard.nextInt() keyboard.nextInt keyboard int M = keyboard.nextInt(); M keyboard.nextInt() keyboard.nextInt keyboard double h = H*30 + M*0.5; h H*30 + M*0.5 H*30 H 30 M*0.5 M 0.5 double m = M*6; m M*6 M 6 System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m)))) System.out.println System.out System System.out Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m)) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(h-m)) B 2*A*B*Math.cos(Math.toRadians(h-m)) 2 A B Math.cos(Math.toRadians(h-m)) Math.cos Math Math.toRadians(h-m) Math.toRadians Math h-m h m keyboard.close() keyboard.close keyboard String[] args args public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
} public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		double A = keyboard.nextDouble();
		double B = keyboard.nextDouble();
		int H = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		double h = H*30 + M*0.5; 
		double m = M*6;
		
		
		System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(h-m))));
		keyboard.close();
	}
}
