import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String A = scan.next(); A scan.next() scan.next scan int a = Integer.parseInt(A); a Integer.parseInt(A) Integer.parseInt Integer A String B = scan.next(); B scan.next() scan.next scan int b = Integer.parseInt(B); b Integer.parseInt(B) Integer.parseInt Integer B String H = scan.next(); H scan.next() scan.next scan int h = Integer.parseInt(H); h Integer.parseInt(H) Integer.parseInt Integer H String M = scan.next(); M scan.next() scan.next scan int m = Integer.parseInt(M); m Integer.parseInt(M) Integer.parseInt Integer M double angle = Math.abs((30 * h + 0.5 * m) - 6 * m); angle Math.abs((30 * h + 0.5 * m) - 6 * m) Math.abs Math (30 * h + 0.5 * m) - 6 * m (30 * h + 0.5 * m) 30 * h 30 h 0.5 * m 0.5 m 6 * m 6 m double cos = Math.cos(Math.toRadians(angle)); cos Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle double ans; ans if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        } angle == 0 angle 0 {
            ans = Math.abs(a - b);
        } ans = Math.abs(a - b) ans Math.abs(a - b) Math.abs Math a - b a b {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        } ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos)) ans Math.sqrt((a * a) + (b * b) - (2 * a * b * cos)) Math.sqrt Math (a * a) + (b * b) - (2 * a * b * cos) (a * a) + (b * b) (a * a) a a (b * b) b b (2 * a * b * cos) b 2 * a * b * cos 2 a b cos System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
} Main
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
}