import java.util.Scanner;
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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
} import java.util.Scanner; Scanner 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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
} 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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    } 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 mm = h + (m / 60.0) ; mm h + (m / 60.0) h (m / 60.0) m 60.0 double cc = Math.cos((5 * mm - m) * Math.PI / 30.0); cc Math.cos((5 * mm - m) * Math.PI / 30.0) Math.cos Math (5 * mm - m) * Math.PI / 30.0 (5 * mm - m) * Math.PI (5 * mm - m) 5 * mm 5 mm m Math.PI Math Math.PI 30.0 double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc); z Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc) Math.sqrt Math a * a * 1.0 + b * b - 2.0 * a * b * cc a * a * 1.0 + b * b a * a * 1.0 a * a * 1.0 a a 1.0 b * b b b 2.0 * a * b * cc b 2.0 * a * b * cc 2.0 a b cc System.out.println(z) System.out.println System.out System System.out z sc.close() sc.close sc 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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
} 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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
} Main
import java.util.Scanner;
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 mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
}