import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    }
} Main public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    } main {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    } Scanner c = new Scanner(System.in); c new Scanner(System.in) double a = c.nextInt(); a c.nextInt() c.nextInt c double b = c.nextInt(); b c.nextInt() c.nextInt c double h = c.nextInt(); h c.nextInt() c.nextInt c double m = c.nextInt(); m c.nextInt() c.nextInt c double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI; angle ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI ((h*60+m)/(12*60))*2*Math.PI ((h*60+m)/(12*60))*2*Math.PI ((h*60+m)/(12*60)) (h*60+m) h*60 h 60 m (12*60) 12 60 2 Math.PI Math Math.PI m/30*Math.PI m/30 m 30 Math.PI Math Math.PI System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle))) System.out.println System.out System System.out Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)) Math.sqrt Math Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle) Math.pow(a,2)+Math.pow(b,2) Math.pow(a,2) Math.pow Math a 2 Math.pow(b,2) Math.pow Math b 2 2*a*b*Math.cos(angle) b 2*a*b*Math.cos(angle) 2 a b Math.cos(angle) Math.cos Math angle String[] args args public class Main {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        double a = c.nextInt();
        double b = c.nextInt();
        double h = c.nextInt();
        double m = c.nextInt();
        double angle = ((h*60+m)/(12*60))*2*Math.PI-m/30*Math.PI;
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angle)));
    }
}
