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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author myob-_-
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

    }
}
 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.Map; Map java.util import java.util.Scanner; Scanner java.util import java.util.HashMap; HashMap 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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

    }
} 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);
        TaskD solver = new TaskD();
        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);
        TaskD solver = new TaskD();
        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) TaskD solver = new TaskD(); solver new TaskD() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

    } TaskD public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    } solve {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    } double a = in.nextDouble(); a in.nextDouble() in.nextDouble in double b = in.nextDouble(); b in.nextDouble() in.nextDouble in double H = in.nextDouble(); H in.nextDouble() in.nextDouble in double M = in.nextDouble(); M in.nextDouble() in.nextDouble in double HH = H*30+ M/2; HH H*30+ M/2 H*30 H 30 M/2 M 2 double MM = M*6; MM M*6 M 6 double ang = Math.abs(HH-MM); ang Math.abs(HH-MM) Math.abs Math HH-MM HH MM ang = Math.min(360-ang, ang) ang Math.min(360-ang, ang) Math.min Math 360-ang 360 ang ang double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang)))); result Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang)))) Math.sqrt Math (a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))) (a*a)+(b*b) (a*a) a a (b*b) b b (2*a*b*Math.cos(Math.toRadians(ang))) b 2*a*b*Math.cos(Math.toRadians(ang)) 2 a b Math.cos(Math.toRadians(ang)) Math.cos Math Math.toRadians(ang) Math.toRadians Math ang out.println(String.format("%.10f", result)) out.println out String.format("%.10f", result) String.format String "%.10f" result 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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

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

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author myob-_-
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        double a = in.nextDouble();
        double b = in.nextDouble();
        double H = in.nextDouble();
        double M = in.nextDouble();
        double HH = H*30+ M/2;
        double MM = M*6;
        double ang = Math.abs(HH-MM);
        ang = Math.min(360-ang, ang);
        double result = Math.sqrt((a*a)+(b*b)-(2*a*b*Math.cos(Math.toRadians(ang))));
        out.println(String.format("%.10f", result));
    }

    }
}

