import java.util.Scanner;
import java.lang.Math;

public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	}
} import java.util.Scanner; Scanner java.util import java.lang.Math; Math java.lang public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	}
} Main public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	} main {
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double  a = scan.nextDouble(); a scan.nextDouble() scan.nextDouble scan double  b = scan.nextDouble(); b scan.nextDouble() scan.nextDouble scan double  h = scan.nextDouble(); h scan.nextDouble() scan.nextDouble scan double  m = scan.nextDouble(); m scan.nextDouble() scan.nextDouble scan double ans = 0; ans 0 h = h * 30 + m * 0.5 h h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 m = m * 6 m m * 6 m 6 double angle = Math.abs(h - m); angle Math.abs(h - m) Math.abs Math h - m h m ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI) ans a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI) a*a + b*b a*a a a b*b b b 2*a*b*Math.cos(angle/180*Math.PI) b 2*a*b*Math.cos(angle/180*Math.PI) 2 a b Math.cos(angle/180*Math.PI) Math.cos Math angle/180*Math.PI angle/180 angle 180 Math.PI Math Math.PI System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String args[] args public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	}
} public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	}
} Main
import java.util.Scanner;
import java.lang.Math;

public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		double  a = scan.nextDouble();
		double  b = scan.nextDouble();
		double  h = scan.nextDouble();
		double  m = scan.nextDouble();
		double ans = 0;
		h = h * 30 + m * 0.5;
		m = m * 6;
		double angle = Math.abs(h - m);
		ans = a*a + b*b -2*a*b*Math.cos(angle/180*Math.PI);
		System.out.println(Math.sqrt(ans));
	}
}