
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a=sc.nextInt(); a sc.nextInt() sc.nextInt sc double b=sc.nextInt(); b sc.nextInt() sc.nextInt sc double h=sc.nextInt(); h sc.nextInt() sc.nextInt sc double m=sc.nextInt(); m sc.nextInt() sc.nextInt sc double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 ); angle Math.toRadians( (h * 30 + m * 0.5) - m * 6 ) Math.toRadians Math (h * 30 + m * 0.5) - m * 6 (h * 30 + m * 0.5) h * 30 h 30 m * 0.5 m 0.5 m * 6 m 6 double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) ); ans Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) ) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(angle) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(angle) b 2 * a * b * Math.cos(angle) 2 a b Math.cos(angle) Math.cos Math angle System.out.printf("%.20f %n", ans) System.out.printf System.out System System.out "%.20f %n" ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();



		double angle = Math.toRadians( (h * 30 + m * 0.5) - m * 6 );
		double ans = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(angle) );

		System.out.printf("%.20f %n", ans);





		sc.close();

	}

}
