import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    }
} Main public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    } main {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    } 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 double h = sc.nextInt(); h sc.nextInt() sc.nextInt sc double m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double theta = (h * 60 + m) / 720 - m / 60; theta (h * 60 + m) / 720 - m / 60 (h * 60 + m) / 720 (h * 60 + m) h * 60 h 60 m 720 m / 60 m 60 theta *= Math.PI * 2 theta Math.PI * 2 Math.PI Math Math.PI 2 System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b)) System.out.println System.out System System.out Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b) Math.sqrt Math - Math.cos(theta) * 2 * a * b + a * a + b * b - Math.cos(theta) * 2 * a * b + a * a + b * b - Math.cos(theta) * 2 * a * b a - Math.cos(theta) * 2 * a * b - Math.cos(theta) Math.cos(theta) Math.cos Math theta 2 a b a * a a a b * b b b String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    }
} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        double h = sc.nextInt();
        double m = sc.nextInt();
        double theta = (h * 60 + m) / 720 - m / 60;
        theta *= Math.PI * 2;
        System.out.println(Math.sqrt(- Math.cos(theta) * 2 * a * b + a * a + b * b));
    }
}