import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String line = reader.readLine(); line reader.readLine() reader.readLine reader String[] strings = new String[4]; strings new String[4] 4 strings = line.split(" ") strings line.split(" ") line.split line " " int[] ints = new int[4]; ints new int[4] 4 for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            ints[i] = Integer.parseInt(strings[i]);
        } {
            ints[i] = Integer.parseInt(strings[i]);
        } ints[i] = Integer.parseInt(strings[i]) ints[i] ints i Integer.parseInt(strings[i]) Integer.parseInt Integer strings[i] strings i int A = ints[0]; A ints[0] ints 0 int B = ints[1]; B ints[1] ints 1 int H = ints[2]; H ints[2] ints 2 int M = ints[3]; M ints[3] ints 3 H =  H % 12 H H % 12 H 12 double Hr = H * 30 + 0.5 * M; Hr H * 30 + 0.5 * M H * 30 H 30 0.5 * M 0.5 M double Mr = M * 6.0; Mr M * 6.0 M 6.0 double cha = Math.abs(Hr - Mr); cha Math.abs(Hr - Mr) Math.abs Math Hr - Mr Hr Mr double jiaoducha = Math.toRadians(cha); jiaoducha Math.toRadians(cha) Math.toRadians Math cha double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha); cq A*A + B*B - 2 * A * B * Math.cos(jiaoducha) A*A + B*B A*A A A B*B B B 2 * A * B * Math.cos(jiaoducha) B 2 * A * B * Math.cos(jiaoducha) 2 A B Math.cos(jiaoducha) Math.cos Math jiaoducha double c = Math.sqrt(cq); c Math.sqrt(cq) Math.sqrt Math cq System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
}
