import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    } main {
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    } 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 ans = 0; ans 0 double hh = h * 30 + 0.5 * m; hh h * 30 + 0.5 * m h * 30 h 30 0.5 * m 0.5 m double mm = 6 * m; mm 6 * m 6 m double hm = (double)Math.abs(hh - mm); hm (double)Math.abs(hh - mm) Math.abs Math hh - mm hh mm double cos = (double)Math.cos(Math.toRadians(hm)); cos (double)Math.cos(Math.toRadians(hm)) Math.cos Math Math.toRadians(hm) Math.toRadians Math hm ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos ans Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos Math.pow(a, 2) + Math.pow(b, 2) Math.pow(a, 2) Math.pow Math a 2 Math.pow(b, 2) Math.pow Math b 2 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){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    }
} Main
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double ans = 0;
        double hh = h * 30 + 0.5 * m;
        double mm = 6 * m;
        double hm = (double)Math.abs(hh - mm);
        double cos = (double)Math.cos(Math.toRadians(hm));
        ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * cos;
        System.out.println(Math.sqrt(ans));
    }
}