import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int m2 = h * 60 + m; m2 h * 60 + m h * 60 h 60 m int rev = 12 * 60; rev 12 * 60 12 60 double hrot = (double)(m2)/rev; hrot (double)(m2)/rev (double)(m2) rev double mrot = (double)(m)/60; mrot (double)(m)/60 (double)(m) 60 double hx = a * Math.sin(2 * Math.PI * hrot); hx a * Math.sin(2 * Math.PI * hrot) a Math.sin(2 * Math.PI * hrot) Math.sin Math 2 * Math.PI * hrot 2 * Math.PI * hrot 2 Math.PI Math Math.PI hrot double hy = a * Math.cos(2 * Math.PI * hrot); hy a * Math.cos(2 * Math.PI * hrot) a Math.cos(2 * Math.PI * hrot) Math.cos Math 2 * Math.PI * hrot 2 * Math.PI * hrot 2 Math.PI Math Math.PI hrot double mx = b * Math.sin(2 * Math.PI * mrot); mx b * Math.sin(2 * Math.PI * mrot) b Math.sin(2 * Math.PI * mrot) Math.sin Math 2 * Math.PI * mrot 2 * Math.PI * mrot 2 Math.PI Math Math.PI mrot double my = b * Math.cos(2 * Math.PI * mrot); my b * Math.cos(2 * Math.PI * mrot) b Math.cos(2 * Math.PI * mrot) Math.cos Math 2 * Math.PI * mrot 2 * Math.PI * mrot 2 Math.PI Math Math.PI mrot double dx = hx - mx; dx hx - mx hx mx double dy = hy - my; dy hy - my hy my double dist = Math.pow(dx * dx + dy * dy, 0.5); dist Math.pow(dx * dx + dy * dy, 0.5) Math.pow Math dx * dx + dy * dy dx * dx dx dx dy * dy dy dy 0.5 System.out.println(dist) System.out.println System.out System System.out dist String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

} Main
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

}