import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	} main {
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) double a=sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b=sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc int h=sc.nextInt(); h sc.nextInt() sc.nextInt sc int m=sc.nextInt(); m sc.nextInt() sc.nextInt sc double ang=Math.abs(30*h-5.5*m); ang Math.abs(30*h-5.5*m) Math.abs Math 30*h-5.5*m 30*h 30 h 5.5*m 5.5 m ang=ang*(Math.PI/180) ang ang*(Math.PI/180) ang (Math.PI/180) Math.PI Math Math.PI 180 System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang))) System.out.println System.out System System.out Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)) Math.sqrt Math a*a+b*b-2*a*b*Math.cos(ang) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(ang) b 2*a*b*Math.cos(ang) 2 a b Math.cos(ang) Math.cos Math ang String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	}
} Main
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		int h=sc.nextInt();
		int m=sc.nextInt();
		double ang=Math.abs(30*h-5.5*m);
		ang=ang*(Math.PI/180);
		System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(ang)));
	}
}
