import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
}
 import java.util.*; util.* java public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	} main {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int M = scan.nextInt(); M scan.nextInt() scan.nextInt scan scan.close() scan.close scan System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180))) System.out.printf System.out System System.out "%4.10f" Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)) Math.sqrt Math A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180) A*A + B*B A*A A A B*B B B 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180) B 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180) 2 A B Math.cos((H*30 - M*5.5) * Math.PI / 180) Math.cos Math (H*30 - M*5.5) * Math.PI / 180 (H*30 - M*5.5) * Math.PI (H*30 - M*5.5) H*30 H 30 M*5.5 M 5.5 Math.PI Math Math.PI 180 String[] args args public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
} public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
}

