import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		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 ma = 360 / 60 * m; ma 360 / 60 * m 360 / 60 360 60 m double ha = 360 / 12 * h + 30.0 / 60 * m; ha 360 / 12 * h + 30.0 / 60 * m 360 / 12 * h 360 / 12 360 12 h 30.0 / 60 * m 30.0 / 60 30.0 60 m double x = Math.abs(ma - ha); x Math.abs(ma - ha) Math.abs Math ma - ha ma ha x = Math.min(x, 360 - x) x Math.min(x, 360 - x) Math.min Math x 360 - x 360 x x = Math.toRadians(x) x Math.toRadians(x) Math.toRadians Math x double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x)); ans Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x)) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(x) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(x) b 2 * a * b * Math.cos(x) 2 a b Math.cos(x) Math.cos Math x 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) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	}
} public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double ma = 360 / 60 * m;
		double ha = 360 / 12 * h + 30.0 / 60 * m;
		
		double x = Math.abs(ma - ha);
		x = Math.min(x, 360 - x);
		x = Math.toRadians(x);
		
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(x));
		
		System.out.println(ans);
		
	}
}