import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    } main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    } 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 double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double kaku = 0; kaku 0 double ans; ans kaku = ((h + m / 60) * 30 ) - m * 6 kaku ((h + m / 60) * 30 ) - m * 6 ((h + m / 60) * 30 ) (h + m / 60) h m / 60 m 60 30 m * 6 m 6 if(kaku > 180){
         kaku = 360 - kaku; 
        } kaku > 180 kaku 180 {
         kaku = 360 - kaku; 
        } kaku = 360 - kaku kaku 360 - kaku 360 kaku ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180)) ans a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180)) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(kaku*(Math.PI/180)) b 2 * a * b * Math.cos(kaku*(Math.PI/180)) 2 a b Math.cos(kaku*(Math.PI/180)) Math.cos Math kaku*(Math.PI/180) kaku (Math.PI/180) Math.PI Math Math.PI 180 ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double kaku = 0;
        double ans;
        kaku = ((h + m / 60) * 30 ) - m * 6;
        if(kaku > 180){
         kaku = 360 - kaku; 
        }
        
        ans = a * a + b * b - 2 * a * b * Math.cos(kaku*(Math.PI/180));
        ans = Math.sqrt(ans);
        
      	System.out.println(ans);
 
    }
}