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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; rect_l m * 360.0 / 60.0 m * 360.0 m 360.0 60.0 double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); rect_s (h * 60.0 + m) * 360.0 / (12.0 * 60.0) (h * 60.0 + m) * 360.0 (h * 60.0 + m) h * 60.0 h 60.0 m 360.0 (12.0 * 60.0) 12.0 60.0 double diff = rect_s - rect_l; diff rect_s - rect_l rect_s rect_l if (diff > 180) diff = 360 - diff; diff > 180 diff 180 diff = 360 - diff diff 360 - diff 360 diff double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0))); ans Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0))) Math.sqrt Math (a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)) (a * a) + (b * b) (a * a) a a (b * b) b b 2 * a * b * Math.cos(diff * (Math.PI / 180.0)) b 2 * a * b * Math.cos(diff * (Math.PI / 180.0)) 2 a b Math.cos(diff * (Math.PI / 180.0)) Math.cos Math diff * (Math.PI / 180.0) diff (Math.PI / 180.0) Math.PI Math Math.PI 180.0 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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            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 rect_l = m * 360.0 / 60.0; //長針
            double rect_s = (h * 60.0 + m) * 360.0 / (12.0 * 60.0); //短針
            double diff = rect_s - rect_l;
            if (diff > 180) diff = 360 - diff;
            double ans = Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(diff * (Math.PI / 180.0)));
            // 出力
            out.printf("%.13f\n", ans);

        }

    }
}

