import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60 + m;
        
        double len = 0;
        double rad = 0;
        double hh = 0;
        double mm = 0;

        for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        }
        hh = hh % 360;
        mm = mm % 360;
        //System.out.println(hh);
        //System.out.println(mm);
        rad = Math.abs(hh - mm);


        len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)));
        System.out.println(len);
    }
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60 + m;
        
        double len = 0;
        double rad = 0;
        double hh = 0;
        double mm = 0;

        for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        }
        hh = hh % 360;
        mm = mm % 360;
        //System.out.println(hh);
        //System.out.println(mm);
        rad = Math.abs(hh - mm);


        len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)));
        System.out.println(len);
    }
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60 + m;
        
        double len = 0;
        double rad = 0;
        double hh = 0;
        double mm = 0;

        for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        }
        hh = hh % 360;
        mm = mm % 360;
        //System.out.println(hh);
        //System.out.println(mm);
        rad = Math.abs(hh - mm);


        len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)));
        System.out.println(len);
    } main {
		Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60 + m;
        
        double len = 0;
        double rad = 0;
        double hh = 0;
        double mm = 0;

        for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        }
        hh = hh % 360;
        mm = mm % 360;
        //System.out.println(hh);
        //System.out.println(mm);
        rad = Math.abs(hh - mm);


        len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)));
        System.out.println(len);
    } 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 int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int time = h*60 + m; time h*60 + m h*60 h 60 m double len = 0; len 0 double rad = 0; rad 0 double hh = 0; hh 0 double mm = 0; mm 0 for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        } int i=0; int i=0; i 0 i<time i time i++ i++ i {
            hh += 0.5;
            mm += 6;
        } {
            hh += 0.5;
            mm += 6;
        } hh += 0.5 hh 0.5 mm += 6 mm 6 hh = hh % 360 hh hh % 360 hh 360 mm = mm % 360 mm mm % 360 mm 360 rad = Math.abs(hh - mm) rad Math.abs(hh - mm) Math.abs Math hh - mm hh mm len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad))) len Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad))) Math.sqrt Math Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)) 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(Math.toRadians(rad)) b 2*a*b* Math.cos(Math.toRadians(rad)) 2 a b Math.cos(Math.toRadians(rad)) Math.cos Math Math.toRadians(rad) Math.toRadians Math rad System.out.println(len) System.out.println System.out System System.out len String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60 + m;
        
        double len = 0;
        double rad = 0;
        double hh = 0;
        double mm = 0;

        for(int i=0; i<time; i++) {
            hh += 0.5;
            mm += 6;
        }
        hh = hh % 360;
        mm = mm % 360;
        //System.out.println(hh);
        //System.out.println(mm);
        rad = Math.abs(hh - mm);


        len = Math.sqrt(Math.pow(a,2)+Math.pow(b,2) - 2*a*b* Math.cos(Math.toRadians(rad)));
        System.out.println(len);
    }
}