import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    }   
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    }   
} Main public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    } main {
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    } Scanner input=new Scanner(System.in); input new Scanner(System.in) int A=input.nextInt(); A input.nextInt() input.nextInt input int B=input.nextInt(); B input.nextInt() input.nextInt input int H=input.nextInt(); H input.nextInt() input.nextInt input int M=input.nextInt(); M input.nextInt() input.nextInt input double angle=Math.abs(5.5*M-H*30)%360; angle Math.abs(5.5*M-H*30)%360 Math.abs(5.5*M-H*30) Math.abs Math 5.5*M-H*30 5.5*M 5.5 M H*30 H 30 360 double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180)); c Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180)) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(Math.PI*angle/180) B 2*A*B*Math.cos(Math.PI*angle/180) 2 A B Math.cos(Math.PI*angle/180) Math.cos Math Math.PI*angle/180 Math.PI*angle Math.PI Math Math.PI angle 180 System.out.print(c) System.out.print System.out System System.out c String[] args args public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    }   
} public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    }   
} Main
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int A=input.nextInt();
        int B=input.nextInt();
        int H=input.nextInt();
        int M=input.nextInt();
        double angle=Math.abs(5.5*M-H*30)%360;
        double c=Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.PI*angle/180));
      System.out.print(c);
    }   
}