import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    }
} Main public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    } main {
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    } Scanner sn = new Scanner(System.in); sn new Scanner(System.in) int A = sn.nextInt(); A sn.nextInt() sn.nextInt sn int B = sn.nextInt(); B sn.nextInt() sn.nextInt sn int H = sn.nextInt(); H sn.nextInt() sn.nextInt sn int M = sn.nextInt(); M sn.nextInt() sn.nextInt sn double HDgree = M*6; HDgree M*6 M 6 double MDgree = H*30; MDgree H*30 H 30 double Dgree = 0; Dgree 0 double n = 0.5*M; n 0.5*M 0.5 M MDgree = MDgree + n MDgree MDgree + n MDgree n if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        } HDgree > MDgree HDgree MDgree {
            Dgree = HDgree - MDgree;
        } Dgree = HDgree - MDgree Dgree HDgree - MDgree HDgree MDgree {
            Dgree = MDgree - HDgree;
        } Dgree = MDgree - HDgree Dgree MDgree - HDgree MDgree HDgree Dgree = Math.abs(Dgree) Dgree Math.abs(Dgree) Math.abs Math Dgree double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree)); c Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree)) 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(Math.toRadians(Dgree)) B 2*A*B*Math.cos(Math.toRadians(Dgree)) 2 A B Math.cos(Math.toRadians(Dgree)) Math.cos Math Math.toRadians(Dgree) Math.toRadians Math Dgree double result = Math.sqrt(c); result Math.sqrt(c) Math.sqrt Math c System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    }
} public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int A = sn.nextInt();
        int B = sn.nextInt();
        int H = sn.nextInt();
        int M = sn.nextInt();

        double HDgree = M*6;
        double MDgree = H*30;
        double Dgree = 0;
        double n = 0.5*M;

        MDgree = MDgree + n;
        
        if(HDgree > MDgree){
            Dgree = HDgree - MDgree;
        }else{
            Dgree = MDgree - HDgree;
        }
        
        Dgree = Math.abs(Dgree);

        double c = Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(Dgree));

        double result = Math.sqrt(c);

        System.out.println(result);
    }
}