
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    
         
    static FastReader in;
    static StringBuilder out;


    public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    }
    public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.lang.reflect.Array; Array java.lang.reflect import java.util.*; util.* java public class Main {
    
         
    static FastReader in;
    static StringBuilder out;


    public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    }
    public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
} Main static FastReader in; in static StringBuilder out; out public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    } dist {
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    } double x2=b*Math.cos(angle) x2 b*Math.cos(angle) b Math.cos(angle) Math.cos Math angle y2=b*Math.sin(angle); y2 b*Math.sin(angle) b Math.sin(angle) Math.sin Math angle return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2); Math.sqrt(Math.pow((x2-x1), 2)+y2*y2) Math.sqrt Math Math.pow((x2-x1), 2)+y2*y2 Math.pow((x2-x1), 2) Math.pow Math (x2-x1) x2 x1 2 y2*y2 y2 y2 int x1 x1 int b b double angle angle public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    } main {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    } in = new FastReader() in new FastReader() int a=in.nextInt() a in.nextInt() in.nextInt in b=in.nextInt() b in.nextInt() in.nextInt in h=in.nextInt() h in.nextInt() in.nextInt in m=in.nextInt(); m in.nextInt() in.nextInt in double minAn=2*Math.PI/60; minAn 2*Math.PI/60 2*Math.PI 2 Math.PI Math Math.PI 60 minAn=minAn*(m%60) minAn minAn*(m%60) minAn (m%60) m 60 double houAn=2*Math.PI/720; houAn 2*Math.PI/720 2*Math.PI 2 Math.PI Math Math.PI 720 houAn=houAn*(((h*60)+m)%720) houAn houAn*(((h*60)+m)%720) houAn (((h*60)+m)%720) ((h*60)+m) (h*60) h 60 m 720 System.out.println(dist(a, b, Math.abs(houAn-minAn))) System.out.println System.out System System.out dist(a, b, Math.abs(houAn-minAn)) dist a b Math.abs(houAn-minAn) Math.abs Math houAn-minAn houAn minAn String[] args args static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastReader {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {
    
         
    static FastReader in;
    static StringBuilder out;


    public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    }
    public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
} public class Main {
    
         
    static FastReader in;
    static StringBuilder out;


    public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    }
    public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    
         
    static FastReader in;
    static StringBuilder out;


    public static double dist(int x1, int b, double angle){
        double x2=b*Math.cos(angle), y2=b*Math.sin(angle);
        return Math.sqrt(Math.pow((x2-x1), 2)+y2*y2);
    }
    public  static void main(String[] args) {
        
        in = new FastReader();
        int a=in.nextInt(),b=in.nextInt(),h=in.nextInt(),m=in.nextInt();
        double minAn=2*Math.PI/60;
        minAn=minAn*(m%60);
        double houAn=2*Math.PI/720;
        houAn=houAn*(((h*60)+m)%720);
        System.out.println(dist(a, b, Math.abs(houAn-minAn)));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
}