import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	} main {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double A = scan.nextDouble(); A scan.nextDouble() scan.nextDouble scan double B = scan.nextDouble(); B scan.nextDouble() scan.nextDouble scan double H = scan.nextDouble(); H scan.nextDouble() scan.nextDouble scan double M = scan.nextDouble(); M scan.nextDouble() scan.nextDouble scan double x = 0d; x 0d double theta = 0d; theta 0d theta = Math.abs(6d * M - (30d * H + 0.5d * M)) theta Math.abs(6d * M - (30d * H + 0.5d * M)) Math.abs Math 6d * M - (30d * H + 0.5d * M) 6d * M 6d M (30d * H + 0.5d * M) 30d * H 30d H 0.5d * M 0.5d M if (theta > 180d) theta = 360d - theta; theta > 180d theta 180d theta = 360d - theta theta 360d - theta 360d theta theta = Math.cos(theta / 360d * 2d * Math.PI) theta Math.cos(theta / 360d * 2d * Math.PI) Math.cos Math theta / 360d * 2d * Math.PI theta / 360d * 2d * Math.PI theta / 360d theta 360d 2d Math.PI Math Math.PI x += A * A x A * A A A x += B * B x B * B B B x -= 2d * A * B * theta x 2d * A * B * theta B 2d * A * B * theta 2d A B theta x = Math.sqrt(x) x Math.sqrt(x) Math.sqrt Math x System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		double x = 0d;
		double theta = 0d;

		theta = Math.abs(6d * M - (30d * H + 0.5d * M));
		if (theta > 180d) theta = 360d - theta;
		theta = Math.cos(theta / 360d * 2d * Math.PI);

		x += A * A;
		x += B * B;
		x -= 2d * A * B * theta;
		x = Math.sqrt(x);

		System.out.println(x);
 	}
}