import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    } main {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextDouble(); A sc.nextDouble() sc.nextDouble sc double B = sc.nextDouble(); B sc.nextDouble() sc.nextDouble sc double H = sc.nextDouble(); H sc.nextDouble() sc.nextDouble sc double M = sc.nextDouble(); M sc.nextDouble() sc.nextDouble sc System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0)))) System.out.println System.out System System.out Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))) Math.sqrt Math A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0)) A*A+B*B A*A A A B*B B B 2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0)) B 2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0)) 2.0 A B Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0)) Math.cos Math 2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0) 2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0) 2.0 Math.PI Math Math.PI (H/12.0+M/12.0/60.0-M/60.0) H/12.0+M/12.0/60.0 H/12.0 H 12.0 M/12.0/60.0 M/12.0/60.0 M 12.0 60.0 M/60.0 M 60.0 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        // System.out.println((H/12.0+M/12.0/60.0-M/60.0));
        System.out.println(Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(2.0*Math.PI*(H/12.0+M/12.0/60.0-M/60.0))));
    }
}