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
 *
 * @author Mehvix
 */
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);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
}
 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);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
} 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);
        abc168_c solver = new abc168_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);
        abc168_c solver = new abc168_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) abc168_c solver = new abc168_c(); solver new abc168_c() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    } abc168_c public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        } solve {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        } double a = fin.nextInt(); a fin.nextInt() fin.nextInt fin double b = fin.nextInt(); b fin.nextInt() fin.nextInt fin double h = fin.nextInt(); h fin.nextInt() fin.nextInt fin double m = fin.nextInt(); m fin.nextInt() fin.nextInt fin double minAng = (m * 6.0); minAng (m * 6.0) m 6.0 double hrAng = (h * 30.0 + minAng / 12.0); hrAng (h * 30.0 + minAng / 12.0) h * 30.0 h 30.0 minAng / 12.0 minAng 12.0 double diffAngl = Math.abs(hrAng - minAng); diffAngl Math.abs(hrAng - minAng) Math.abs Math hrAng - minAng hrAng minAng fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl)))))) fout.println fout Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))) Math.sqrt Math (a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl)))) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos((Math.toRadians(diffAngl))) b 2 * a * b * Math.cos((Math.toRadians(diffAngl))) 2 a b Math.cos((Math.toRadians(diffAngl))) Math.cos Math (Math.toRadians(diffAngl)) Math.toRadians Math diffAngl int testNumber testNumber Scanner fin fin PrintWriter fout fout 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);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
} 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);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
} 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
 *
 * @author Mehvix
 */
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);
        abc168_c solver = new abc168_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_c {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            double a = fin.nextInt();  // hr len
            double b = fin.nextInt();  // min len
            double h = fin.nextInt();
            double m = fin.nextInt();

            double minAng = (m * 6.0);
            double hrAng = (h * 30.0 + minAng / 12.0);
            double diffAngl = Math.abs(hrAng - minAng);

//        System.out.println(diffAngl);

            fout.println(Math.sqrt((a * a + b * b - 2 * a * b * Math.cos((Math.toRadians(diffAngl))))));

        }

    }
}

