import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
} import java.util.Scanner; Scanner java.util import java.lang.Math; Math java.lang public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    } main {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num1 = sc.nextInt(); num1 sc.nextInt() sc.nextInt sc int num2 = sc.nextInt(); num2 sc.nextInt() sc.nextInt sc int hour = sc.nextInt(); hour sc.nextInt() sc.nextInt sc int min = sc.nextInt(); min sc.nextInt() sc.nextInt sc double degOfMin = min*6; degOfMin min*6 min 6 double degOfHour = hour*30 + degOfMin/12; degOfHour hour*30 + degOfMin/12 hour*30 hour 30 degOfMin/12 degOfMin 12 double deg = Math.abs(degOfHour - degOfMin); deg Math.abs(degOfHour - degOfMin) Math.abs Math degOfHour - degOfMin degOfHour degOfMin if (deg > 180){deg = 360 - deg;} deg > 180 deg 180 {deg = 360 - deg;} deg = 360 - deg deg 360 - deg 360 deg double rad = Math.toRadians(deg); rad Math.toRadians(deg) Math.toRadians Math deg double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad)); num3 (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad)) (num1*num1) + (num2*num2) (num1*num1) num1 num1 (num2*num2) num2 num2 (2*num1*num2*Math.cos(rad)) num2 2*num1*num2*Math.cos(rad) 2 num1 num2 Math.cos(rad) Math.cos Math rad System.out.print(Math.sqrt(num3)) System.out.print System.out System System.out Math.sqrt(num3) Math.sqrt Math num3 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
} Main
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
}