import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  } main {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int M = scan.nextInt(); M scan.nextInt() scan.nextInt scan double h = (H + (double)M/60)*30; h (H + (double)M/60)*30 (H + (double)M/60) H (double)M/60 (double)M 60 30 double m = (double)M*6; m (double)M*6 (double)M 6 double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m))); ans Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m))) Math.sqrt Math A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(h-m)) B 2*A*B*Math.cos(Math.toRadians(h-m)) 2 A B Math.cos(Math.toRadians(h-m)) Math.cos Math Math.toRadians(h-m) Math.toRadians Math h-m h m 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 scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  }
} Main
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int H = scan.nextInt();
    int M = scan.nextInt();
    double h = (H + (double)M/60)*30;
    double m = (double)M*6;
    double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.toRadians(h-m)));
    System.out.println(ans);
  }
}