import java.util.*;
import java.math.BigInteger;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
} import java.util.*; util.* java import java.math.BigInteger; BigInteger java.math public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
} Main public static final int MOD = (int)1e9+7; MOD (int)1e9+7 (int)1e9 7 public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    } main {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double h = Integer.parseInt(sc.next()); h Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double hs = h/12+m/60/12; hs h/12+m/60/12 h/12 h 12 m/60/12 m/60/12 m 60 12 double ms = m/60; ms m/60 m 60 double e = Math.abs(hs-ms)*360; e Math.abs(hs-ms)*360 Math.abs(hs-ms) Math.abs Math hs-ms hs ms 360 double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e)); c a*a+b*b-2*a*b*Math.cos(Math.toRadians(e)) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(Math.toRadians(e)) b 2*a*b*Math.cos(Math.toRadians(e)) 2 a b Math.cos(Math.toRadians(e)) Math.cos Math Math.toRadians(e) Math.toRadians Math e System.out.println(Math.sqrt(c)) System.out.println System.out System System.out Math.sqrt(c) Math.sqrt Math c String[] args args public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
} public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
} Main
import java.util.*;
import java.math.BigInteger;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double h = Integer.parseInt(sc.next());
        double m = Integer.parseInt(sc.next());
        double hs = h/12+m/60/12;
        double ms = m/60;
        double e = Math.abs(hs-ms)*360;
        
        double c = a*a+b*b-2*a*b*Math.cos(Math.toRadians(e));
        System.out.println(Math.sqrt(c));
        
    }
}
