import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Random;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    }

    private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    }

    private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }


} import java.io.BufferedInputStream; BufferedInputStream java.io import java.io.BufferedOutputStream; BufferedOutputStream 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.Random; Random java.util public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    }

    private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    }

    private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }


} Main public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    } main {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    } try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        } {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        } BufferedInputStream in = new BufferedInputStream(System.in) BufferedInputStream in = new BufferedInputStream(System.in) new BufferedInputStream(System.in) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) new PrintWriter(new BufferedOutputStream(System.out)) _Scanner sc = new _Scanner(in); sc new _Scanner(in) double a = sc.nextInt(); a sc.nextInt() sc.nextInt sc double b = sc.nextInt(); b sc.nextInt() sc.nextInt sc double h = sc.nextInt(); h sc.nextInt() sc.nextInt sc double m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double full = Math.PI * 2; full Math.PI * 2 Math.PI Math Math.PI 2 Point ap = point(a, full * ((h + m / 60.0) / 12.0)); ap point(a, full * ((h + m / 60.0) / 12.0)) point a full * ((h + m / 60.0) / 12.0) full ((h + m / 60.0) / 12.0) (h + m / 60.0) h m / 60.0 m 60.0 12.0 Point bp = point(b, full * m / 60.0); bp point(b, full * m / 60.0) point b full * m / 60.0 full * m full m 60.0 double dx = bp.x - ap.x; dx bp.x - ap.x bp.x bp bp.x ap.x ap ap.x double dy = bp.y - ap.y; dy bp.y - ap.y bp.y bp bp.y ap.y ap ap.y double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); dist Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)) Math.sqrt Math Math.pow(dx, 2) + Math.pow(dy, 2) Math.pow(dx, 2) Math.pow Math dx 2 Math.pow(dy, 2) Math.pow Math dy 2 out.println(dist) out.println out dist String[] args args private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    } point {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    } double x = r * Math.sin(deg); x r * Math.sin(deg) r Math.sin(deg) Math.sin Math deg double y = r * Math.cos(deg); y r * Math.cos(deg) r Math.cos(deg) Math.cos Math deg return new Point(x, y); new Point(x, y) double r r double deg deg private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    } reverse {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    } for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        } int i = 0; int i = 0; i 0 i < vs.length / 2 i vs.length / 2 vs.length vs vs.length 2 i++ i++ i {
            swap(vs, i, vs.length - 1 - i);
        } {
            swap(vs, i, vs.length - 1 - i);
        } swap(vs, i, vs.length - 1 - i) swap vs i vs.length - 1 - i vs.length - 1 - i vs.length vs vs.length 1 i int[] vs vs private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    } shuffle {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    } Random rnd = new Random(); rnd new Random() for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } int i = 0; int i = 0; i 0 i < ar.length i ar.length ar ar.length i++ i++ i {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } int j = i + rnd.nextInt(ar.length - i); j i + rnd.nextInt(ar.length - i) i rnd.nextInt(ar.length - i) rnd.nextInt rnd ar.length - i ar.length ar ar.length i swap(ar, i, j) swap ar i j int[] ar ar private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    } shuffle {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    } Random rnd = new Random(); rnd new Random() for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } int i = 0; int i = 0; i 0 i < ar.length i ar.length ar ar.length i++ i++ i {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        } int j = i + rnd.nextInt(ar.length - i); j i + rnd.nextInt(ar.length - i) i rnd.nextInt(ar.length - i) rnd.nextInt rnd ar.length - i ar.length ar ar.length i swap(ar, i, j) swap ar i j Object[] ar ar private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    } swap {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    } int t = ar[i]; t ar[i] ar i ar[i] = ar[j] ar[i] ar i ar[j] ar j ar[j] = t ar[j] ar j t int[] ar ar int i i int j j private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    } swap {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    } Object t = ar[i]; t ar[i] ar i ar[i] = ar[j] ar[i] ar i ar[j] ar j ar[j] = t ar[j] ar j t Object[] ar ar int i i int j j private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    } Point double x x y; y public Point(double x, double y) {
            this.x = x;
            this.y = y;
        } Point {
            this.x = x;
            this.y = y;
        } this.x = x this.x this this.x x this.y = y this.y this this.y y double x x double y y @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        } toString {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        } return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}'; "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}' y ", y=" x "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}' "Point{" "x=" x ", y=" y '}' static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    } _Scanner InputStream is; is byte[] bb = new byte[1 << 15]; bb new byte[1 << 15] 1 << 15 1 15 int k k l; l _Scanner(InputStream is) {
            this.is = is;
        } _Scanner {
            this.is = is;
        } this.is = is this.is this this.is is InputStream is is byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } getc {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } 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) {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                } k >= l k l {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                } k = 0 k 0 l = is.read(bb) l is.read(bb) is.read is bb if (l < 0) return -1; l < 0 l 0 return -1; -1 1 return bb[k++]; bb[k++] bb k++ k byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        } skip {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        } byte b; b while ((b = getc()) <= 32)
                ; (b = getc()) <= 32 (b = getc()) b getc() getc 32 return b; b int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        } nextInt {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        } int n = 0; n 0 int sig = 1; sig 1 for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } byte b = skip(); byte b = skip(); b skip() skip b > 32 b 32 b = getc() b = getc() b getc() getc {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                } b == '-' b '-' {
                    sig = -1;
                } sig = -1 sig -1 1 {
                    n = n * 10 + b - '0';
                } n = n * 10 + b - '0' n n * 10 + b - '0' n * 10 + b n * 10 n 10 b '0' return sig * n; sig * n sig n long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        } nextLong {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        } long n = 0; n 0 long sig = 1; sig 1 for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } byte b = skip(); byte b = skip(); b skip() skip b > 32 b 32 b = getc() b = getc() b getc() getc {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            } if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                } b == '-' b '-' {
                    sig = -1;
                } sig = -1 sig -1 1 {
                    n = n * 10 + b - '0';
                } n = n * 10 + b - '0' n n * 10 + b - '0' n * 10 + b n * 10 n 10 b '0' return sig * n; sig * n sig n public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        } next {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        } StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            } int b = skip(); int b = skip(); b skip() skip b > 32 b 32 b = getc() b = getc() b getc() getc {
                sb.append(((char) b));
            } {
                sb.append(((char) b));
            } sb.append(((char) b)) sb.append sb ((char) b) return sb.toString(); sb.toString() sb.toString sb public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    }

    private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    }

    private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }


} public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    }

    private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    }

    private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }


} Main
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Random;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            _Scanner sc = new _Scanner(in);

            double a = sc.nextInt();
            double b = sc.nextInt();

            double h = sc.nextInt();
            double m = sc.nextInt();

            double full = Math.PI * 2;
//            double full = Math.PI;
            Point ap = point(a, full * ((h + m / 60.0) / 12.0));
            Point bp = point(b, full * m / 60.0);

            double dx = bp.x - ap.x;
            double dy = bp.y - ap.y;

            double dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

            out.println(dist);
        }
    }

    private static Point point(double r, double deg) {
        double x = r * Math.sin(deg);
        double y = r * Math.cos(deg);
        return new Point(x, y);
    }

    private static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    private static void reverse(int[] vs) {
        for (int i = 0; i < vs.length / 2; i++) {
            swap(vs, i, vs.length - 1 - i);
        }
    }

    static class _Scanner {
        InputStream is;
        _Scanner(InputStream is) {
            this.is = is;
        }
        byte[] bb = new byte[1 << 15];
        int k, l;
        byte getc() {
            try {
                if (k >= l) {
                    k = 0;
                    l = is.read(bb);
                    if (l < 0) return -1;
                }
                return bb[k++];
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        byte skip() {
            byte b;
            while ((b = getc()) <= 32)
                ;
            return b;
        }

        int nextInt() {
            int n = 0;
            int sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        long nextLong() {
            long n = 0;
            long sig = 1;
            for (byte b = skip(); b > 32; b = getc()) {
                if (b == '-') {
                    sig = -1;
                } else {
                    n = n * 10 + b - '0';
                }
            }
            return sig * n;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); b > 32; b = getc()) {
                sb.append(((char) b));
            }
            return sb.toString();
        }
    }

    private static void shuffle(int[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void shuffle(Object[] ar) {
        Random rnd = new Random();
        for (int i = 0; i < ar.length; i++) {
            int j = i + rnd.nextInt(ar.length - i);
            swap(ar, i, j);
        }
    }

    private static void swap(int[] ar, int i, int j) {
        int t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }

    private static void swap(Object[] ar, int i, int j) {
        Object t = ar[i];
        ar[i] = ar[j];
        ar[j] = t;
    }


}
