import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    }
} Main public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    } main {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double ans = 0; ans 0 double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5))); X Math.abs((M * 6) - ((H * 30) + (M * 0.5))) Math.abs Math (M * 6) - ((H * 30) + (M * 0.5)) (M * 6) M 6 ((H * 30) + (M * 0.5)) (H * 30) H 30 (M * 0.5) M 0.5 if(X > 180){
    		X = 360 - X;
    	} X > 180 X 180 {
    		X = 360 - X;
    	} X = 360 - X X 360 - X 360 X double cos = Math.cos(Math.toRadians(X)); cos Math.cos(Math.toRadians(X)) Math.cos Math Math.toRadians(X) Math.toRadians Math X ans = a*a + b*b - 2 * a * b * cos ans a*a + b*b - 2 * a * b * cos a*a + b*b a*a a a b*b b b 2 * a * b * cos b 2 * a * b * cos 2 a b cos System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    }
} public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	int H = sc.nextInt();
    	int M = sc.nextInt();
    	sc.close();
    	double ans = 0;
    	double X = Math.abs((M * 6) - ((H * 30) + (M * 0.5)));
    	if(X > 180){
    		X = 360 - X;
    	}
    	double cos = Math.cos(Math.toRadians(X));
    	ans = a*a + b*b - 2 * a * b * cos;
    	System.out.println(Math.sqrt(ans));
    }
}