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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
} 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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
} 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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  } 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 m_angle = 6.0 * m; m_angle 6.0 * m 6.0 m double h_angle = (30.0 * h) + (0.5 * m); h_angle (30.0 * h) + (0.5 * m) (30.0 * h) 30.0 h (0.5 * m) 0.5 m double mh_angle = Math.abs(h_angle - m_angle); mh_angle Math.abs(h_angle - m_angle) Math.abs Math h_angle - m_angle h_angle m_angle double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle)); cc (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle)) (a * a) + (b * b) (a * a) a a (b * b) b b 2 * a * b * Math.cos(Math.toRadians(mh_angle)) b 2 * a * b * Math.cos(Math.toRadians(mh_angle)) 2 a b Math.cos(Math.toRadians(mh_angle)) Math.cos Math Math.toRadians(mh_angle) Math.toRadians Math mh_angle System.out.println(Math.sqrt(cc)) System.out.println System.out System System.out Math.sqrt(cc) Math.sqrt Math cc 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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
} 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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
} 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 m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
}