import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	} main {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	} Scanner s = new Scanner(System.in); s new Scanner(System.in) double A = s.nextDouble(); A s.nextDouble() s.nextDouble s double B = s.nextDouble(); B s.nextDouble() s.nextDouble s double H = s.nextDouble(); H s.nextDouble() s.nextDouble s double M = s.nextDouble(); M s.nextDouble() s.nextDouble s double radb = Math.toRadians((M*360)/60); radb Math.toRadians((M*360)/60) Math.toRadians Math (M*360)/60 (M*360) M 360 60 double rada = Math.toRadians((360*H/12)+(360*M/720)); rada Math.toRadians((360*H/12)+(360*M/720)) Math.toRadians Math (360*H/12)+(360*M/720) (360*H/12) 360*H 360 H 12 (360*M/720) 360*M 360 M 720 double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb)); ans Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb)) Math.sqrt Math A*A + B*B - 2*A*B*Math.cos(rada-radb) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(rada-radb) B 2*A*B*Math.cos(rada-radb) 2 A B Math.cos(rada-radb) Math.cos Math rada-radb rada radb System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

} public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double A = s.nextDouble();// 時針の長さ
        double B = s.nextDouble(); //分針の長さ
        double H = s.nextDouble();
        double M = s.nextDouble();
        

        double radb = Math.toRadians((M*360)/60);
        double rada = Math.toRadians((360*H/12)+(360*M/720));

 /*       System.out.println((M*360)/60+" "+((360*H/12)+(360*M/720))); //孤度法
        System.out.println(radb+" "+rada); //ラジアン */

        double ans =
        		Math.sqrt(A*A + B*B - 2*A*B*Math.cos(rada-radb));

        System.out.println(ans);
      



	}

}
