import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double angleH = 0; angleH 0 double angleM = 0; angleM 0 angleH = H * 30 + M * 0.5 angleH H * 30 + M * 0.5 H * 30 H 30 M * 0.5 M 0.5 angleM = M * 6 angleM M * 6 M 6 double angle = angleH - angleM; angle angleH - angleM angleH angleM double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle))); ans Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle))) Math.sqrt Math Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)) Math.pow(A,2) + Math.pow(B,2) Math.pow(A,2) Math.pow Math A 2 Math.pow(B,2) Math.pow Math B 2 2 * A * B * Math.cos(Math.toRadians(angle)) B 2 * A * B * Math.cos(Math.toRadians(angle)) 2 A B Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.print(ans) System.out.print System.out System System.out ans String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	}
}