import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	} main {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int a = stdIn.nextInt(); a stdIn.nextInt() stdIn.nextInt stdIn int b = stdIn.nextInt(); b stdIn.nextInt() stdIn.nextInt stdIn int h = stdIn.nextInt(); h stdIn.nextInt() stdIn.nextInt stdIn int m = stdIn.nextInt(); m stdIn.nextInt() stdIn.nextInt stdIn double thour = 30 * h + 30 * m / 60.0; thour 30 * h + 30 * m / 60.0 30 * h 30 h 30 * m / 60.0 30 * m 30 m 60.0 double mhour = 6 * m; mhour 6 * m 6 m double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour)); kakudo (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour)) (Math.abs(thour - mhour))<180 (Math.abs(thour - mhour)) Math.abs Math thour - mhour thour mhour 180 Math.abs(thour - mhour) Math.abs Math thour - mhour thour mhour 360-(Math.abs(thour - mhour)) 360 (Math.abs(thour - mhour)) Math.abs Math thour - mhour thour mhour double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); tmp b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))) b * b + a * a b * b b b a * a a a (2 * a * b * Math.cos(Math.toRadians(kakudo))) b 2 * a * b * Math.cos(Math.toRadians(kakudo)) 2 a b Math.cos(Math.toRadians(kakudo)) Math.cos Math Math.toRadians(kakudo) Math.toRadians Math kakudo System.out.println(Math.sqrt(tmp)) System.out.println System.out System System.out Math.sqrt(tmp) Math.sqrt Math tmp String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();

		int b = stdIn.nextInt();

		int h = stdIn.nextInt();

		int m = stdIn.nextInt();


		double thour = 30 * h + 30 * m / 60.0;

		double mhour = 6 * m;


		double kakudo = (Math.abs(thour - mhour))<180 ?Math.abs(thour - mhour):360-(Math.abs(thour - mhour));
		
	
		double tmp = b * b + a * a - (2 * a * b * Math.cos(Math.toRadians(kakudo))); 

		
		System.out.println(Math.sqrt(tmp));
		
	}

}
