import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    } main {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double h = Double.parseDouble(sc.next()); h Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double m = Double.parseDouble(sc.next()); m Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI)); res Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI)) Math.sqrt Math Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI) 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 * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI) b 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI) 2 a b Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI) Math.cos Math Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI Math.abs((h + m / 60) / 12 - m / 60) Math.abs Math (h + m / 60) / 12 - m / 60 (h + m / 60) / 12 (h + m / 60) h m / 60 m 60 12 m / 60 m 60 2 Math.PI Math Math.PI System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    }
} public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        double res = Math.sqrt(
                Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.abs((h + m / 60) / 12 - m / 60) * 2 * Math.PI));
        System.out.println(res);  
    }
}