import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	} main {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A=sc.nextInt(); A sc.nextInt() sc.nextInt sc double Ad=(double)A; Ad (double)A int B=sc.nextInt(); B sc.nextInt() sc.nextInt sc double Bd=(double)B; Bd (double)B int H=sc.nextInt(); H sc.nextInt() sc.nextInt sc int M=sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double arg arg C; C arg=(double)H*30.0+(double)M*0.5-(double)M*6.0 arg (double)H*30.0+(double)M*0.5-(double)M*6.0 (double)H*30.0+(double)M*0.5 (double)H*30.0 (double)H 30.0 (double)M*0.5 (double)M 0.5 (double)M*6.0 (double)M 6.0 C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg))) C Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg))) Math.sqrt Math Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)) Ad*Ad+Bd*Bd Ad*Ad Ad Ad Bd*Bd Bd Bd 2.0*Ad*Bd*Math.cos(Math.toRadians(arg)) Bd 2.0*Ad*Bd*Math.cos(Math.toRadians(arg)) 2.0 Ad Bd Math.cos(Math.toRadians(arg)) Math.cos Math Math.toRadians(arg) Math.toRadians Math arg System.out.println(C) System.out.println System.out System System.out C String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
}
