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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  }
} 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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  }
} 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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  } 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 int keika = 60 * h + m; keika 60 * h + m 60 * h 60 h m double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6)); seta Math.toRadians(Math.abs(keika * 0.5 - m * 6)) Math.toRadians Math Math.abs(keika * 0.5 - m * 6) Math.abs Math keika * 0.5 - m * 6 keika * 0.5 keika 0.5 m * 6 m 6 System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta))) System.out.println System.out System System.out Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)) Math.sqrt Math Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta) Math.pow(a, 2) + Math.pow(b, 2) Math.pow(a, 2) Math.pow Math a 2 Math.pow(b, 2) Math.pow Math b 2 2 * a * b * Math.cos(seta) b 2 * a * b * Math.cos(seta) 2 a b Math.cos(seta) Math.cos Math seta 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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  }
} 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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  }
} 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();

    int keika = 60 * h + m;
    double seta = Math.toRadians(Math.abs(keika * 0.5 - m * 6));
    System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(seta)));
  }
}
