import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	} 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 angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI; angle Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0) Math.abs Math (double)h/12+((double)m/60)/12.0 -(double)m/60.0 (double)h/12+((double)m/60)/12.0 (double)h/12 (double)h 12 ((double)m/60)/12.0 ((double)m/60) (double)m 60 12.0 (double)m/60.0 (double)m 60.0 2 Math.PI Math Math.PI double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle); res (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle) (double)a*a +(double)b*b (double)a*a (double)a a (double)b*b (double)b b (double) 2*a*b*Math.cos(angle) b (double) 2*a*b*Math.cos(angle) (double) 2 a b Math.cos(angle) Math.cos Math angle res =Math.sqrt(res) res Math.sqrt(res) Math.sqrt Math res System.out.printf("%.20f",res) System.out.printf System.out System System.out "%.20f" res String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		double angle= Math.abs((double)h/12+((double)m/60)/12.0 -(double)m/60.0)*2*Math.PI;
		double res= (double)a*a +(double)b*b -(double) 2*a*b*Math.cos(angle);
		res =Math.sqrt(res);

        System.out.printf("%.20f",res);
	}

}
