
import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

} import java.util.Scanner; Scanner java.util public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

} Main public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	} main {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a a b b h h m; m a = sc.nextDouble() a sc.nextDouble() sc.nextDouble sc b = sc.nextDouble() b sc.nextDouble() sc.nextDouble sc h = sc.nextDouble() h sc.nextDouble() sc.nextDouble sc m = sc.nextDouble() m sc.nextDouble() sc.nextDouble sc double a2 = 30 * h + m * 0.5; a2 30 * h + m * 0.5 30 * h 30 h m * 0.5 m 0.5 double b2 = 6 * m; b2 6 * m 6 m double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2))); c2 Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2))) Math.min Math Math.abs(a2 - b2) Math.abs Math a2 - b2 a2 b2 Math.abs(360 - (a2 - b2)) Math.abs Math 360 - (a2 - b2) 360 (a2 - b2) a2 b2 double pi = c2 / 180 * Math.PI; pi c2 / 180 * Math.PI c2 / 180 c2 180 Math.PI Math Math.PI double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)); tou Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(pi) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(pi) b 2 * a * b * Math.cos(pi) 2 a b Math.cos(pi) Math.cos Math pi System.out.println(tou) System.out.println System.out System System.out tou String[] args args public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

} public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

} Main

import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		double a, b, h, m;
	        a = sc.nextDouble();
	        b = sc.nextDouble();
	        h = sc.nextDouble();
	        m = sc.nextDouble();
	        
	        double a2 = 30 * h + m * 0.5;
	        double b2 = 6 * m;
	        
	        double c2 = Math.min(Math.abs(a2 - b2) , Math.abs(360 - (a2 - b2)));
	        double pi = c2 / 180 * Math.PI;
	        double tou = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi));
	        System.out.println(tou);
	
	}

}