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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(ans)));

        }

    } C public void solve(int testNumber, Scanner in, PrintWriter out) {
            int longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(ans)));

        } solve {
            int longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(ans)));

        } int longDistance = in.nextInt(); longDistance in.nextInt() in.nextInt in int shortDistance = in.nextInt(); shortDistance in.nextInt() in.nextInt in int hour = in.nextInt(); hour in.nextInt() in.nextInt in int minute = in.nextInt(); minute in.nextInt() in.nextInt in double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360; kakudo ((double) (60 * hour + minute) / (60 * 12)) * 360 ((double) (60 * hour + minute) / (60 * 12)) (double) (60 * hour + minute) 60 * hour 60 hour minute (60 * 12) 60 12 360 double kakudoShort = ((double) minute / 60) * 360; kakudoShort ((double) minute / 60) * 360 ((double) minute / 60) (double) minute 60 360 double diff = Math.abs(kakudo - kakudoShort); diff Math.abs(kakudo - kakudoShort) Math.abs Math kakudo - kakudoShort kakudo kakudoShort double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff))); ans Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff))) Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) Math.pow(longDistance, 2) Math.pow Math longDistance 2 Math.pow(shortDistance, 2) Math.pow Math shortDistance 2 (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff))) shortDistance 2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)) 2 longDistance shortDistance Math.cos(Math.toRadians(diff)) Math.cos Math Math.toRadians(diff) Math.toRadians Math diff out.append(String.valueOf(Math.sqrt(ans))) out.append out String.valueOf(Math.sqrt(ans)) String.valueOf String Math.sqrt(ans) Math.sqrt Math 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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(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 longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double kakudo = ((double) (60 * hour + minute) / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(ans)));

        }

    }
}

