import java.util.Scanner;

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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
} import java.util.Scanner; Scanner 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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
} 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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    } main {
        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    } 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 int h = Integer.parseInt(sc.next()); h Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double timeSpeed = 360. / 12 / 60; timeSpeed 360. / 12 / 60 360. / 12 / 60 360. 12 60 double minuteSpeed = 360. / 1 / 60; minuteSpeed 360. / 1 / 60 360. / 1 / 60 360. 1 60 double x = (minuteSpeed - timeSpeed) * (h * 60 + m); x (minuteSpeed - timeSpeed) * (h * 60 + m) (minuteSpeed - timeSpeed) minuteSpeed timeSpeed (h * 60 + m) h * 60 h 60 m double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180); c2 a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(x * Math.PI / 180) b 2 * a * b * Math.cos(x * Math.PI / 180) 2 a b Math.cos(x * Math.PI / 180) Math.cos Math x * Math.PI / 180 x * Math.PI x Math.PI Math Math.PI 180 System.out.println(Math.sqrt(c2)) System.out.println System.out System System.out Math.sqrt(c2) Math.sqrt Math c2 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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
} 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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
} Main
import java.util.Scanner;

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());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
}