import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double h_kakudo = 30 * h + (double)m / 2; h_kakudo 30 * h + (double)m / 2 30 * h 30 h (double)m / 2 (double)m 2 double m_kakudo = 6 * m; m_kakudo 6 * m 6 m double kakudo_sa = Math.abs(h_kakudo - m_kakudo); kakudo_sa Math.abs(h_kakudo - m_kakudo) Math.abs Math h_kakudo - m_kakudo h_kakudo m_kakudo if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; kakudo_sa > 180 kakudo_sa 180 kakudo_sa = 360 - kakudo_sa kakudo_sa 360 - kakudo_sa 360 kakudo_sa if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		} kakudo_sa == 0 kakudo_sa 0 System.out.println(Math.abs(a - b)) System.out.println System.out System System.out Math.abs(a - b) Math.abs Math a - b a b if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		} kakudo_sa == 180 kakudo_sa 180 System.out.println(a + b) System.out.println System.out System System.out a + b a b {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		} double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa)); c_2 Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa)) Math.pow(a, 2) + Math.pow(b, 2) Math.pow(a, 2) Math.pow Math a 2 Math.pow(b, 2) Math.pow Math b 2 2 * a * b * Math.cos(Math.toRadians(kakudo_sa)) b 2 * a * b * Math.cos(Math.toRadians(kakudo_sa)) 2 a b Math.cos(Math.toRadians(kakudo_sa)) Math.cos Math Math.toRadians(kakudo_sa) Math.toRadians Math kakudo_sa double ans = Math.sqrt(c_2); ans Math.sqrt(c_2) Math.sqrt Math c_2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double h_kakudo = 30 * h + (double)m / 2;
		double m_kakudo = 6 * m;
		
		double kakudo_sa = Math.abs(h_kakudo - m_kakudo);
		if(kakudo_sa > 180) kakudo_sa = 360 - kakudo_sa; 
		
		if(kakudo_sa == 0) System.out.println(Math.abs(a - b));
		else if(kakudo_sa == 180) System.out.println(a + b);
		else {
			double c_2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo_sa));
			double ans = Math.sqrt(c_2);
			System.out.println(ans);
		}
		
	}

}
