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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
} 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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
} 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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	} main {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double h = scan.nextDouble();
		double m = scan.nextDouble();

		double ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	} 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 ah = 0; ah 0 double am = 0; am 0 am = m * 6 am m * 6 m 6 ah = h * 30 + m / 2 ah h * 30 + m / 2 h * 30 h 30 m / 2 m 2 double angle = Math.abs(am - ah); angle Math.abs(am - ah) Math.abs Math am - ah am ah if(angle > 180) {
			angle = 360 - angle;
		} angle > 180 angle 180 {
			angle = 360 - angle;
		} angle = 360 - angle angle 360 - angle 360 angle double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle))); r Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle))) Math.sqrt Math Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)) Math.pow(b,2)+Math.pow(a,2) Math.pow(b,2) Math.pow Math b 2 Math.pow(a,2) Math.pow Math a 2 2*b*a*Math.cos(Math.toRadians(angle)) a 2*b*a*Math.cos(Math.toRadians(angle)) 2 b a Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(r) System.out.println System.out System System.out r 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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
} 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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
} 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 ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
}