import java.util.*;

public class Main {
  static final double H_SPEED = 2*Math.PI/720;
  static final double M_SPEED = 2*Math.PI/60;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  }
} import java.util.*; util.* java public class Main {
  static final double H_SPEED = 2*Math.PI/720;
  static final double M_SPEED = 2*Math.PI/60;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  }
} Main static final double H_SPEED = 2*Math.PI/720; H_SPEED 2*Math.PI/720 2*Math.PI 2 Math.PI Math Math.PI 720 static final double M_SPEED = 2*Math.PI/60; M_SPEED 2*Math.PI/60 2*Math.PI 2 Math.PI Math Math.PI 60 public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED)); res Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED)) Math.sqrt Math a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED) b 2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED) 2 a b Math.cos((60*h+m)*H_SPEED-m*M_SPEED) Math.cos Math (60*h+m)*H_SPEED-m*M_SPEED (60*h+m)*H_SPEED (60*h+m) 60*h 60 h m H_SPEED m*M_SPEED m M_SPEED System.out.println(res) System.out.println System.out System System.out res sc.close() sc.close sc String[] args args public class Main {
  static final double H_SPEED = 2*Math.PI/720;
  static final double M_SPEED = 2*Math.PI/60;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  }
} public class Main {
  static final double H_SPEED = 2*Math.PI/720;
  static final double M_SPEED = 2*Math.PI/60;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  }
} Main
import java.util.*;

public class Main {
  static final double H_SPEED = 2*Math.PI/720;
  static final double M_SPEED = 2*Math.PI/60;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    double res = Math.sqrt(a*a+b*b-2*a*b*Math.cos((60*h+m)*H_SPEED-m*M_SPEED));
    System.out.println(res);
    sc.close();
  }
}