import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
} Main public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	} main {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	} Scanner scr =new Scanner(System.in); scr new Scanner(System.in) int A = scr.nextInt(); A scr.nextInt() scr.nextInt scr int B = scr.nextInt(); B scr.nextInt() scr.nextInt scr int H = scr.nextInt(); H scr.nextInt() scr.nextInt scr int M = scr.nextInt(); M scr.nextInt() scr.nextInt scr double H1 = (H*60+M)*0.5; H1 (H*60+M)*0.5 (H*60+M) H*60 H 60 M 0.5 double M1 = M*6; M1 M*6 M 6 double KK; KK if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		} H1 < M1 H1 M1 {
			KK = M1-H1;
		} KK = M1-H1 KK M1-H1 M1 H1 {
			KK = H1-M1;
		} KK = H1-M1 KK H1-M1 H1 M1 double Theta = Math.cos(Math.toRadians(KK)); Theta Math.cos(Math.toRadians(KK)) Math.cos Math Math.toRadians(KK) Math.toRadians Math KK double ans = A*A+B*B-2*B*A*Theta; ans A*A+B*B-2*B*A*Theta A*A+B*B A*A A A B*B B B 2*B*A*Theta A 2*B*A*Theta 2 B A Theta 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 scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
}