import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    }
} Main public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    } main {
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextInt(); A sc.nextInt() sc.nextInt sc double B = sc.nextInt(); B sc.nextInt() sc.nextInt sc double H = sc.nextInt(); H sc.nextInt() sc.nextInt sc double M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double theta = (double)Math.abs((H*30+0.5*M)-M*6); theta (double)Math.abs((H*30+0.5*M)-M*6) Math.abs Math (H*30+0.5*M)-M*6 (H*30+0.5*M) H*30 H 30 0.5*M 0.5 M M*6 M 6 if(theta>=180){
        theta=(double)360.0-theta;
      } theta>=180 theta 180 {
        theta=(double)360.0-theta;
      } theta=(double)360.0-theta theta (double)360.0-theta (double)360.0 theta double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta)); ans A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta)) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(theta)) B 2*A*B*Math.cos(Math.toRadians(theta)) 2 A B Math.cos(Math.toRadians(theta)) Math.cos Math Math.toRadians(theta) Math.toRadians Math theta ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    }
} public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      // 取得
	  double A = sc.nextInt();
      double B = sc.nextInt();
      double H = sc.nextInt();
      double M = sc.nextInt();
      double theta = (double)Math.abs((H*30+0.5*M)-M*6);
      if(theta>=180){
        theta=(double)360.0-theta;
      }
      double ans = A*A+B*B-2*A*B*Math.cos(Math.toRadians(theta));
      ans = Math.sqrt(ans);
      System.out.println(ans);
    }
}