import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc final int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc final int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc final int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double rad = Math.toRadians((60*H + M)* 0.5 - M*6); rad Math.toRadians((60*H + M)* 0.5 - M*6) Math.toRadians Math (60*H + M)* 0.5 - M*6 (60*H + M)* 0.5 (60*H + M) 60*H 60 H M 0.5 M*6 M 6 double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad)); ans Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad)) Math.sqrt Math Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad) Math.pow(A, 2.0) + Math.pow(B, 2.0) Math.pow(A, 2.0) Math.pow Math A 2.0 Math.pow(B, 2.0) Math.pow Math B 2.0 2*A*B*Math.cos(rad) B 2*A*B*Math.cos(rad) 2 A B Math.cos(rad) Math.cos Math rad 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);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    final int H = sc.nextInt();
    final int M = sc.nextInt();
    sc.close();
    double rad = Math.toRadians((60*H + M)* 0.5 - M*6);
    double ans = Math.sqrt(Math.pow(A, 2.0) + Math.pow(B, 2.0) - 2*A*B*Math.cos(rad));
    System.out.println(ans);
  }
}