 import java.util.Scanner;

public 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  }
}   import java.util.Scanner; Scanner java.util public 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  }
} 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  } main {
    Scanner sc = new Scanner(System.in);
    int A=sc.nextInt();
    int B=sc.nextInt();
    int H=sc.nextInt();
    int M=sc.nextInt();
    double x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  } 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 x=M*6; x M*6 M 6 double y=H*30+M*0.5; y H*30+M*0.5 H*30 H 30 M*0.5 M 0.5 double t=Math.abs(x-y); t Math.abs(x-y) Math.abs Math x-y x y double rad=t*3.141592653589/180; rad t*3.141592653589/180 t*3.141592653589 t 3.141592653589 180 double cos=Math.cos(rad); cos Math.cos(rad) Math.cos Math rad double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos)); X Math.sqrt((A*A)+(B*B)-(2*A*B*cos)) Math.sqrt Math (A*A)+(B*B)-(2*A*B*cos) (A*A)+(B*B) (A*A) A A (B*B) B B (2*A*B*cos) B 2*A*B*cos 2 A B cos System.out.println(X) System.out.println System.out System System.out X String[] args args public 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  }
} public 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  }
} Main
 import java.util.Scanner;

public 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 x=M*6;
    double y=H*30+M*0.5;
    double t=Math.abs(x-y);
    double rad=t*3.141592653589/180;
    double cos=Math.cos(rad);
    double X=Math.sqrt((A*A)+(B*B)-(2*A*B*cos));
    System.out.println(X);
  }
}  