import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      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);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } 
} Main public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } main {
        Scanner sc= new Scanner(System.in);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } Scanner sc= new Scanner(System.in); sc new Scanner(System.in) int hour = sc.nextInt(); hour sc.nextInt() sc.nextInt sc int minute = sc.nextInt(); minute 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 Hrad = (30 * H) + (0.5 * M) ; Hrad (30 * H) + (0.5 * M) (30 * H) 30 H (0.5 * M) 0.5 M double Mrad = 6 * M ; Mrad 6 * M 6 M double cos; cos if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      } Hrad >= Mrad Hrad Mrad {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } cos = Math.cos(Math.toRadians(Hrad - Mrad)) cos Math.cos(Math.toRadians(Hrad - Mrad)) Math.cos Math Math.toRadians(Hrad - Mrad) Math.toRadians Math Hrad - Mrad Hrad Mrad {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      } cos = Math.cos(Math.toRadians(Mrad - Hrad)) cos Math.cos(Math.toRadians(Mrad - Hrad)) Math.cos Math Math.toRadians(Mrad - Hrad) Math.toRadians Math Mrad - Hrad Mrad Hrad double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos); a2 (hour * hour) + (minute * minute) -(2 * hour * minute * cos) (hour * hour) + (minute * minute) (hour * hour) hour hour (minute * minute) minute minute (2 * hour * minute * cos) minute 2 * hour * minute * cos 2 hour minute cos double ans = Math.sqrt(a2); ans Math.sqrt(a2) Math.sqrt Math a2 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);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } 
} public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } 
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int hour = sc.nextInt();
      int minute = sc.nextInt();
      int H = sc.nextInt();
      int M = sc.nextInt();
      double Hrad = (30 * H) + (0.5 * M) ;
//      System.out.println(Hrad);
      double Mrad = 6 * M ;
//      System.out.println(Mrad);
      double cos;
      if(Hrad >= Mrad) {
        cos = Math.cos(Math.toRadians(Hrad - Mrad));
      } else {
        cos = Math.cos(Math.toRadians(Mrad - Hrad));
      }
      double a2 = (hour * hour) + (minute * minute) -(2 * hour * minute * cos);
      double ans = Math.sqrt(a2);
      System.out.println(ans);
    } 
}