import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    double a;
    double b;
    double h;
    double m;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    double a;
    double b;
    double h;
    double m;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    }
} Main // 変数一覧
    double a; a double b; b double h; h double m; m public static void main(String[] args) {
        Main main = new Main();
        main.run();
    } main {
        Main main = new Main();
        main.run();
    } Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    } run {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) a = sc.nextDouble() a sc.nextDouble() sc.nextDouble sc b = sc.nextDouble() b sc.nextDouble() sc.nextDouble sc h = sc.nextDouble() h sc.nextDouble() sc.nextDouble sc m = sc.nextDouble() m sc.nextDouble() sc.nextDouble sc sc.close() sc.close sc solve() solve private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    } solve {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    } double m_deg = m * 6.0; m_deg m * 6.0 m 6.0 double h_deg = 0.5 * (60.0 * h + m); h_deg 0.5 * (60.0 * h + m) 0.5 (60.0 * h + m) 60.0 * h 60.0 h m double deg = 0; deg 0 if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        } h_deg > m_deg h_deg m_deg {
            deg = h_deg - m_deg;
        } deg = h_deg - m_deg deg h_deg - m_deg h_deg m_deg {
            deg = m_deg - h_deg;
        } deg = m_deg - h_deg deg m_deg - h_deg m_deg h_deg if (deg > 180.0) {
            deg = 360 - deg;
        } deg > 180.0 deg 180.0 {
            deg = 360 - deg;
        } deg = 360 - deg deg 360 - deg 360 deg double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg)))); ans Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg)))) Math.sqrt Math Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))) Math.pow(a, 2.0) + Math.pow(b, 2.0) Math.pow(a, 2.0) Math.pow Math a 2.0 Math.pow(b, 2.0) Math.pow Math b 2.0 (2.0 * a * b * Math.cos(Math.toRadians(deg))) b 2.0 * a * b * Math.cos(Math.toRadians(deg)) 2.0 a b Math.cos(Math.toRadians(deg)) Math.cos Math Math.toRadians(deg) Math.toRadians Math deg System.out.println(ans) System.out.println System.out System System.out ans public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    double a;
    double b;
    double h;
    double m;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    double a;
    double b;
    double h;
    double m;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    double a;
    double b;
    double h;
    double m;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        
        double m_deg = m * 6.0;
        double h_deg = 0.5 * (60.0 * h + m);
        double deg = 0;
        if (h_deg > m_deg) {
            deg = h_deg - m_deg;
        } else {
            deg = m_deg - h_deg;
        }

        if (deg > 180.0) {
            deg = 360 - deg;
        }

        double ans = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - (2.0 * a * b * Math.cos(Math.toRadians(deg))));

        System.out.println(ans);
    }
}