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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
} 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
} 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	} main {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		//固定端を原点として，デカルト座標系における各針の先端の座標を計算．
		double Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	} 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360); Ax A * Math.sin(Math.PI * ((60 * H) + M) / 360) A Math.sin(Math.PI * ((60 * H) + M) / 360) Math.sin Math Math.PI * ((60 * H) + M) / 360 Math.PI * ((60 * H) + M) Math.PI Math Math.PI ((60 * H) + M) (60 * H) 60 H M 360 double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360); Ay A * Math.cos(Math.PI * ((60 * H) + M) / 360) A Math.cos(Math.PI * ((60 * H) + M) / 360) Math.cos Math Math.PI * ((60 * H) + M) / 360 Math.PI * ((60 * H) + M) Math.PI Math Math.PI ((60 * H) + M) (60 * H) 60 H M 360 double Bx = B * Math.sin(Math.PI * M / 30); Bx B * Math.sin(Math.PI * M / 30) B Math.sin(Math.PI * M / 30) Math.sin Math Math.PI * M / 30 Math.PI * M Math.PI Math Math.PI M 30 double By = B * Math.cos(Math.PI * M / 30); By B * Math.cos(Math.PI * M / 30) B Math.cos(Math.PI * M / 30) Math.cos Math Math.PI * M / 30 Math.PI * M Math.PI Math Math.PI M 30 double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By); d_square (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By) (Ax - Bx) * (Ax - Bx) (Ax - Bx) Ax Bx (Ax - Bx) Ax Bx (Ay - By) * (Ay - By) (Ay - By) Ay By (Ay - By) Ay By double d = Math.sqrt(d_square); d Math.sqrt(d_square) Math.sqrt Math d_square System.out.println(d) System.out.println System.out System System.out d 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
} 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
} 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 Ax = A * Math.sin(Math.PI * ((60 * H) + M) / 360);
		double Ay = A * Math.cos(Math.PI * ((60 * H) + M) / 360);

		double Bx = B * Math.sin(Math.PI * M / 30);
		double By = B * Math.cos(Math.PI * M / 30);

		double d_square = (Ax - Bx) * (Ax - Bx) + (Ay - By) * (Ay - By);
		double d = Math.sqrt(d_square);

		System.out.println(d);
	}
}
