import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) C solver = new C(); solver new C() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    } C public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        } solve {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        } int a = Integer.parseInt(in.next()); a Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int b = Integer.parseInt(in.next()); b Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int h = Integer.parseInt(in.next()); h Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int m = Integer.parseInt(in.next()); m Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in double min = h * 60.0 + m; min h * 60.0 + m h * 60.0 h 60.0 m double rect = 5.5 * min; rect 5.5 * min 5.5 min double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect))); ans Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect))) Math.sqrt Math ((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)) ((double) a * (double) a) + ((double) b * (double) b) ((double) a * (double) a) (double) a (double) a ((double) b * (double) b) (double) b (double) b 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)) (double) b 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)) 2.0 (double) a (double) b Math.cos(Math.toRadians(rect)) Math.cos Math Math.toRadians(rect) Math.toRadians Math rect out.printf("%.13f\n", ans) out.printf out "%.13f\n" ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            double min = h * 60.0 + m;
            double rect = 5.5 * min;
            double ans = Math.sqrt(((double) a * (double) a) + ((double) b * (double) b) - 2.0 * (double) a * (double) b * Math.cos(Math.toRadians(rect)));
            out.printf("%.13f\n", ans);

        }

    }
}

