import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    } main {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    } Scanner input = new Scanner(System.in); input new Scanner(System.in) double a = input.nextDouble(); a input.nextDouble() input.nextDouble input double b = input.nextDouble(); b input.nextDouble() input.nextDouble input double h = input.nextDouble(); h input.nextDouble() input.nextDouble input double m = input.nextDouble(); m input.nextDouble() input.nextDouble input double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0); radian Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0) Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0) Math.PI Math Math.PI 2 (h/12.0 + (m/60.0)/12.0 - m / 60.0) h/12.0 + (m/60.0)/12.0 h/12.0 h 12.0 (m/60.0)/12.0 (m/60.0) m 60.0 12.0 m / 60.0 m 60.0 double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian); rsq (a*a+b*b) - (2*a*b)*Math.cos(radian) (a*a+b*b) a*a a a b*b b b (2*a*b)*Math.cos(radian) (2*a*b) 2*a*b 2 a b Math.cos(radian) Math.cos Math radian System.out.println(Math.sqrt(rsq)) System.out.println System.out System System.out Math.sqrt(rsq) Math.sqrt Math rsq String[] args args public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    }
} public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double h = input.nextDouble();
        double m = input.nextDouble();

        double radian = Math.PI*2*(h/12.0 + (m/60.0)/12.0 - m / 60.0);

        double rsq = (a*a+b*b) - (2*a*b)*Math.cos(radian);

        System.out.println(Math.sqrt(rsq));

    }
}