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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

} 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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

} 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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        double h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    } 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 h = 30 * (H + M/60.0); h 30 * (H + M/60.0) 30 (H + M/60.0) H M/60.0 M 60.0 double m = M * 6.0; m M * 6.0 M 6.0 double k = Math.abs(m - h); k Math.abs(m - h) Math.abs Math m - h m h double cos = Math.cos(Math.toRadians(k)); cos Math.cos(Math.toRadians(k)) Math.cos Math Math.toRadians(k) Math.toRadians Math k double a = A*A + B*B - (2*A*B*cos); a A*A + B*B - (2*A*B*cos) A*A + B*B A*A A A B*B B B (2*A*B*cos) B 2*A*B*cos 2 A B cos System.out.println(Math.sqrt(a)) System.out.println System.out System System.out Math.sqrt(a) Math.sqrt Math a 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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

} 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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

} 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 h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

}