import java.io.InputStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
} import java.io.InputStream; InputStream java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
} Main public static void main(String[] args) {
		new Main().execute(System.in);
	} main {
		new Main().execute(System.in);
	} new Main().execute(System.in) new Main().execute new Main() System.in System System.in String[] args args public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	} execute {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	} Scanner sc = new Scanner(in); sc new Scanner(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 rh = (h + (m / 60.0)) * 360 / 12.0; rh (h + (m / 60.0)) * 360 / 12.0 (h + (m / 60.0)) * 360 (h + (m / 60.0)) h (m / 60.0) m 60.0 360 12.0 double rm = (m * 360 / 60.0); rm (m * 360 / 60.0) m * 360 m 360 60.0 double r = Math.abs(rh - rm); r Math.abs(rh - rm) Math.abs Math rh - rm rh rm r = Math.toRadians(r) r Math.toRadians(r) Math.toRadians Math r double c = a * a + b * b - 2 * a * b * Math.cos(r); c a * a + b * b - 2 * a * b * Math.cos(r) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(r) b 2 * a * b * Math.cos(r) 2 a b Math.cos(r) Math.cos Math r c = Math.sqrt(c) c Math.sqrt(c) Math.sqrt Math c System.out.println(c) System.out.println System.out System System.out c sc.close() sc.close sc InputStream in in public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
} Main
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
}
