import 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  }
} import java.util.*; util.* java 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  }
} 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  } main {
    Scanner sc =new Scanner(System.in);
    int A =sc.nextInt();
    int B =sc.nextInt();
    int H =sc.nextInt();
    int M =sc.nextInt();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  } 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 if(H>=12){H =H-12;} H>=12 H 12 {H =H-12;} H =H-12 H H-12 H 12 double K =Math.abs(H*30+M*0.5-M*6); K Math.abs(H*30+M*0.5-M*6) Math.abs Math H*30+M*0.5-M*6 H*30+M*0.5 H*30 H 30 M*0.5 M 0.5 M*6 M 6 double k =Math.cos(Math.toRadians(K)); k Math.cos(Math.toRadians(K)) Math.cos Math Math.toRadians(K) Math.toRadians Math K double T =A*A+B*B-2*A*B*k; T A*A+B*B-2*A*B*k A*A+B*B A*A A A B*B B B 2*A*B*k B 2*A*B*k 2 A B k double t =Math.sqrt(T); t Math.sqrt(T) Math.sqrt Math T System.out.println(t) System.out.println System.out System System.out t 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  }
} 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  }
} Main
import 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();
    if(H>=12){H =H-12;}
    double K =Math.abs(H*30+M*0.5-M*6);
    double k =Math.cos(Math.toRadians(K));
    double T =A*A+B*B-2*A*B*k;
    double t =Math.sqrt(T);
    System.out.println(t);
  }
}