import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Collections; Collections java.util public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	} main {
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	} 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 Short = (double)(h * (360 / 12)) + (double)m * 1/2; Short (double)(h * (360 / 12)) + (double)m * 1/2 (double)(h * (360 / 12)) h (360 / 12) 360 12 (double)m * 1/2 (double)m * 1 (double)m 1 2 double Long = (double)m * (360 / 60); Long (double)m * (360 / 60) (double)m (360 / 60) 360 60 double ang = (double)Math.abs(Long - Short); ang (double)Math.abs(Long - Short) Math.abs Math Long - Short Long Short double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang))); ans (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang))) (double)a * a + b * b (double)a * a (double)a a b * b b b 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang))) b 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang))) 2 a b Math.cos(Math.toRadians(Math.min(ang, 360 - ang))) Math.cos Math Math.toRadians(Math.min(ang, 360 - ang)) Math.toRadians Math Math.min(ang, 360 - ang) Math.min Math ang 360 - ang 360 ang System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
} public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
} Main
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        
        double Short = (double)(h * (360 / 12)) + (double)m * 1/2;

        double Long = (double)m * (360 / 60);

        double ang = (double)Math.abs(Long - Short);
        //System.out.println(ang);

        double ans = (double)a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(Math.min(ang, 360 - ang)));
        
        System.out.println(Math.sqrt(ans));
    
	}
}