import java.io.*;
import java.util.*;
public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
} Main private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    } solver {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double hour_angle = (0.5 * (h*60 + m)); hour_angle (0.5 * (h*60 + m)) 0.5 (h*60 + m) h*60 h 60 m int minute_angle = (6*m); minute_angle (6*m) 6 m double angle = Math.abs(hour_angle - minute_angle); angle Math.abs(hour_angle - minute_angle) Math.abs Math hour_angle - minute_angle hour_angle minute_angle angle = Math.min(360-angle, angle) angle Math.min(360-angle, angle) Math.min Math 360-angle 360 angle angle angle = Math.toRadians(angle) angle Math.toRadians(angle) Math.toRadians Math angle double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle))); ans (a *a) + (b*b) - (2 *a * b * (Math.cos(angle))) (a *a) + (b*b) (a *a) a a (b*b) b b (2 *a * b * (Math.cos(angle))) b 2 *a * b * (Math.cos(angle)) 2 a b (Math.cos(angle)) Math.cos Math angle ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans out.printf("%.10f",ans) out.printf out "%.10f" ans InputReader sc sc PrintWriter out out public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out InputReader in = new InputReader(inputStream); in new InputReader(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) solver(in,out) solver in out out.close() out.close out String[] args args static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    } InputReader public BufferedReader reader; reader public StringTokenizer tokenizer; tokenizer public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } InputReader {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(stream), 32768) reader new BufferedReader(new InputStreamReader(stream), 32768) tokenizer = null tokenizer null InputStream stream stream public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        } readIntArray {
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        } int arr[] = new int[n]; arr new int[n] n for(int i=0;i<n;i++) arr[i] = nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i arr[i] = nextInt(); arr[i] = nextInt() arr[i] arr i nextInt() nextInt return arr; arr int n n class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
} Pair int x x y; y Pair(int x, int y){
        this.x = x;
        this.y = y;
    } Pair {
        this.x = x;
        this.y = y;
    } this.x = x this.x this this.x x this.y = y this.y this this.y y int x x int y y @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    } equals {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    } if (this == o) return true; this == o this o return true; true if (o == null || getClass() != o.getClass()) return false; o == null || getClass() != o.getClass() o == null o null getClass() != o.getClass() getClass() getClass o.getClass() o.getClass o return false; false Pair pair = (Pair) o; pair (Pair) o return x == pair.x &&
                y == pair.y; x == pair.x &&
                y == pair.y x == pair.x x pair.x pair pair.x y == pair.y y pair.y pair pair.y Object o o @Override
    public int hashCode() {
        return Objects.hash(x, y);
    } hashCode {
        return Objects.hash(x, y);
    } return Objects.hash(x, y); Objects.hash(x, y) Objects.hash Objects x y public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
} public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
} Main
import java.io.*;
import java.util.*;
public class Main {

    private static void solver(InputReader sc, PrintWriter out) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double hour_angle = (0.5 * (h*60 + m));
        int minute_angle = (6*m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360-angle, angle);
        angle = Math.toRadians(angle);
        double ans = (a *a) + (b*b) - (2 *a * b * (Math.cos(angle)));
        ans = Math.sqrt(ans);
        out.printf("%.10f",ans);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}