
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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	}
} 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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	}
} 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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	} 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 double xLong = 0; xLong 0 double yLong = 0; yLong 0 double xShort = 0; xShort 0 double yShort = 0; yShort 0 double ans = 0; ans 0 double ThetaLong = 0; ThetaLong 0 double ThetaShort = 0; ThetaShort 0 double minute = H * 60 + M; minute H * 60 + M H * 60 H 60 M if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		} H < 3 H 3 {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		} ThetaShort = 90 - 0.5 * minute ThetaShort 90 - 0.5 * minute 90 0.5 * minute 0.5 minute xShort = A * Math.cos(Math.toRadians(ThetaShort)) xShort A * Math.cos(Math.toRadians(ThetaShort)) A Math.cos(Math.toRadians(ThetaShort)) Math.cos Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort yShort = A * Math.sin(Math.toRadians(ThetaShort)) yShort A * Math.sin(Math.toRadians(ThetaShort)) A Math.sin(Math.toRadians(ThetaShort)) Math.sin Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		} H < 6 H 6 {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		} ThetaShort = 0.5 * minute - 90 ThetaShort 0.5 * minute - 90 0.5 * minute 0.5 minute 90 xShort = A * Math.cos(Math.toRadians(ThetaShort)) xShort A * Math.cos(Math.toRadians(ThetaShort)) A Math.cos(Math.toRadians(ThetaShort)) Math.cos Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort yShort = -A * Math.sin(Math.toRadians(ThetaShort)) yShort -A * Math.sin(Math.toRadians(ThetaShort)) -A A Math.sin(Math.toRadians(ThetaShort)) Math.sin Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		} H < 9 H 9 {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		} ThetaShort = 270 - 0.5 * minute ThetaShort 270 - 0.5 * minute 270 0.5 * minute 0.5 minute xShort = -A * Math.cos(Math.toRadians(ThetaShort)) xShort -A * Math.cos(Math.toRadians(ThetaShort)) -A A Math.cos(Math.toRadians(ThetaShort)) Math.cos Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort yShort = -A * Math.sin(Math.toRadians(ThetaShort)) yShort -A * Math.sin(Math.toRadians(ThetaShort)) -A A Math.sin(Math.toRadians(ThetaShort)) Math.sin Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		} ThetaShort = 0.5 * minute - 270 ThetaShort 0.5 * minute - 270 0.5 * minute 0.5 minute 270 xShort = -A * Math.cos(Math.toRadians(ThetaShort)) xShort -A * Math.cos(Math.toRadians(ThetaShort)) -A A Math.cos(Math.toRadians(ThetaShort)) Math.cos Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort yShort = A * Math.sin(Math.toRadians(ThetaShort)) yShort A * Math.sin(Math.toRadians(ThetaShort)) A Math.sin(Math.toRadians(ThetaShort)) Math.sin Math Math.toRadians(ThetaShort) Math.toRadians Math ThetaShort if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		} M < 15 M 15 {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		} ThetaLong = 90 - 6 * M ThetaLong 90 - 6 * M 90 6 * M 6 M xLong = B * Math.cos(Math.toRadians(ThetaLong)) xLong B * Math.cos(Math.toRadians(ThetaLong)) B Math.cos(Math.toRadians(ThetaLong)) Math.cos Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong yLong = B * Math.sin(Math.toRadians(ThetaLong)) yLong B * Math.sin(Math.toRadians(ThetaLong)) B Math.sin(Math.toRadians(ThetaLong)) Math.sin Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		} M < 30 M 30 {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		} ThetaLong = 6 * M - 90 ThetaLong 6 * M - 90 6 * M 6 M 90 xLong = B * Math.cos(Math.toRadians(ThetaLong)) xLong B * Math.cos(Math.toRadians(ThetaLong)) B Math.cos(Math.toRadians(ThetaLong)) Math.cos Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong yLong = -B * Math.sin(Math.toRadians(ThetaLong)) yLong -B * Math.sin(Math.toRadians(ThetaLong)) -B B Math.sin(Math.toRadians(ThetaLong)) Math.sin Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		} M < 45 M 45 {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		} ThetaLong = 270 - 6 * M ThetaLong 270 - 6 * M 270 6 * M 6 M xLong = -B * Math.cos(Math.toRadians(ThetaLong)) xLong -B * Math.cos(Math.toRadians(ThetaLong)) -B B Math.cos(Math.toRadians(ThetaLong)) Math.cos Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong yLong = -B * Math.sin(Math.toRadians(ThetaLong)) yLong -B * Math.sin(Math.toRadians(ThetaLong)) -B B Math.sin(Math.toRadians(ThetaLong)) Math.sin Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		} ThetaLong = 6 * M - 270 ThetaLong 6 * M - 270 6 * M 6 M 270 xLong = -B * Math.cos(Math.toRadians(ThetaLong)) xLong -B * Math.cos(Math.toRadians(ThetaLong)) -B B Math.cos(Math.toRadians(ThetaLong)) Math.cos Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong yLong = B * Math.sin(Math.toRadians(ThetaLong)) yLong B * Math.sin(Math.toRadians(ThetaLong)) B Math.sin(Math.toRadians(ThetaLong)) Math.sin Math Math.toRadians(ThetaLong) Math.toRadians Math ThetaLong ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2)) ans Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2)) Math.sqrt Math Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2) Math.pow(xShort-xLong, 2) Math.pow Math xShort-xLong xShort xLong 2 Math.pow(yShort-yLong, 2) Math.pow Math yShort-yLong yShort yLong 2 System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan 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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	}
} 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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	}
} 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();
		double xLong = 0;
		double yLong = 0;
		double xShort = 0;
		double yShort = 0;
		double ans = 0;

		double ThetaLong = 0;
		double ThetaShort = 0;

		double minute = H * 60 + M;

		if(H < 3) {
			ThetaShort = 90 - 0.5 * minute;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 6) {
			ThetaShort = 0.5 * minute - 90;
			xShort = A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else if(H < 9) {
			ThetaShort = 270 - 0.5 * minute;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = -A * Math.sin(Math.toRadians(ThetaShort));
		}else {
			ThetaShort = 0.5 * minute - 270;
			xShort = -A * Math.cos(Math.toRadians(ThetaShort));
			yShort = A * Math.sin(Math.toRadians(ThetaShort));
		}

		if(M < 15) {
			ThetaLong = 90 - 6 * M;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 30) {
			ThetaLong = 6 * M - 90;
			xLong = B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else if(M < 45) {
			ThetaLong = 270 - 6 * M;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = -B * Math.sin(Math.toRadians(ThetaLong));
		}else {
			ThetaLong = 6 * M - 270;
			xLong = -B * Math.cos(Math.toRadians(ThetaLong));
			yLong = B * Math.sin(Math.toRadians(ThetaLong));
		}

		ans = Math.sqrt( Math.pow(xShort-xLong, 2) + Math.pow(yShort-yLong, 2));
		System.out.println(ans);

		scan.close();
	}
}
