import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
} Main public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    } main {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    } MyScanner sc = new MyScanner(); sc new MyScanner() 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 double angH = 30 * h + 0.5 * m; angH 30 * h + 0.5 * m 30 * h 30 h 0.5 * m 0.5 m double angM = 6 * m; angM 6 * m 6 m double disAng = Math.abs(angH - angM); disAng Math.abs(angH - angM) Math.abs Math angH - angM angH angM if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        } disAng == 0 disAng 0 {
            System.out.println(Math.abs(a - b));
            return;
        } System.out.println(Math.abs(a - b)) System.out.println System.out System System.out Math.abs(a - b) Math.abs Math a - b a b return; double angC = disAng; angC disAng if (disAng > 180)
            angC = 360 - disAng; disAng > 180 disAng 180 angC = 360 - disAng angC 360 - disAng 360 disAng double cosC = Math.cos(Math.toRadians(angC)); cosC Math.cos(Math.toRadians(angC)) Math.cos Math Math.toRadians(angC) Math.toRadians Math angC double c = a * a + b * b - 2 * a * b * cosC; c a * a + b * b - 2 * a * b * cosC a * a + b * b a * a a a b * b b b 2 * a * b * cosC b 2 * a * b * cosC 2 a b cosC System.out.println(Math.sqrt(c)) System.out.println System.out System System.out Math.sqrt(c) Math.sqrt Math c String[] args args static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    } MyScanner BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15); reader new BufferedReader(new InputStreamReader(System.in), 1 << 15) StringTokenizer tokenizer; tokenizer String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        } next {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        } try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            } catch (IOException ignored) {
            } IOException ignored {
            } {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer 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 public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
} public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angH = 30 * h + 0.5 * m;
        double angM = 6 * m;
        double disAng = Math.abs(angH - angM);

        if (disAng == 0) {
            System.out.println(Math.abs(a - b));
            return;
        }

        double angC = disAng;
        if (disAng > 180)
            angC = 360 - disAng;
        double cosC = Math.cos(Math.toRadians(angC));
        double c = a * a + b * b - 2 * a * b * cosC;

        System.out.println(Math.sqrt(c));
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
