#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

// fill container
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


namespace geo {

using value_type = long double;
using Point = std::complex<value_type>;

const value_type eps = 1e-12;
const value_type pi = 3.14159265358979323846264338327950288419716939937510L;

const value_type err_v = std::numeric_limits<value_type>::max();
const Point err_p(err_v, err_v);

struct DualPoints : public std::pair<Point, Point> {
    using std::pair<Point, Point>::pair;

    Point& operator [](size_t idx) { return idx == 0 ? first : second; }
    
    const Point& operator [](size_t idx) const { return idx == 0 ? first : second; }
};

struct get_xy {
    value_type &x, &y;

    get_xy(value_type &x, value_type &y) : x(x), y(y) { }

    get_xy& operator =(const Point &p) {
        x = std::real(p);
        y = std::imag(p);
        return *this;
    }
};

struct Circle {
    Point p;
    value_type r;

    Circle(Point p, value_type r) : p(p), r(r) { }
};

struct Line : public DualPoints {
    using DualPoints::DualPoints;
};

struct Seg : public DualPoints {
    using DualPoints::DualPoints;
};

value_type dot(const Point &a, const Point &b) {
    return (std::conj(a) * b).real();
}

value_type cross(const Point &a, const Point &b) {
    return (std::conj(a) * b).imag();
}

bool is_zero(value_type a) {
    return std::abs(a) <= eps;
}

bool eq(value_type a, value_type b) {
    return is_zero(a - b);
}

// projection from p to l
Point proj(const Line &l, const Point &p) {
    value_type mul = dot(p - l[0], l[1] - l[0]) / norm(l[0] - l[1]);  // cos(theta) / (p-l[0]).norm()
    return l[0] + mul * (l[1] - l[0]);
}

Point refl(const Line &l, const Point &p) {
    Point pr = proj(l, p);
    return p + ((pr - p) * static_cast<value_type>(2));
}

value_type fix_arg(value_type arg) {
    while (arg < 0) arg += 2 * pi;
    while (2 * pi <= arg) arg -= 2 * pi;
    return arg;
}

value_type fix_arg(const Point &a) {
    return fix_arg(std::arg(a));
}

bool comp_coclock(const Point &p1, const Point &p2) {
    return fix_arg(arg(p1)) < fix_arg(arg(p2));
}

Point rotate(const Point &p, value_type arg) {
    std::complex<value_type> r(std::cos(arg), std::sin(arg));
    return p * r;
}

value_type cos(value_type a, value_type b, value_type c) {
    return (a * a + b * b - c * c) / (2 * a * b);
}

bool is_parallel(const Line &l1, const Line &l2) {
    return is_zero(cross(l1[1] - l1[0], l2[1] - l2[0]));
}

bool is_same_line(Point o, Point a, Point b) {
    return is_zero(cross(a - o, b - o));
}

}

namespace geo {

/*      
 * Point c is
 *
 *         1
 * -----------------
 *  -2  a  0  b  2
 * -----------------
 *        -1
 */

int ccw(Point a, Point b, Point c) {
    b -= a;
    c -= a;
    value_type p, q;
    {
        auto tmp = std::conj(b) * c;
        p = tmp.real();
        q = tmp.imag();
    }
    if (0 < q) return 1;
    if (q < 0) return -1;
    if (p < 0) return 2;
    if (std::norm(b) < std::norm(c)) return -2;
    return 0;
}

}

namespace geo {

bool intersect(const Line &p, const Line &q) {
    if (!is_parallel(p, q)) return true;
    return is_same_line(p[0], p[1], q[1]);
}

bool intersect(const Line &l, const Seg &s) {
    value_type a = cross(l[1] - l[0], s[0] - l[0]);
    value_type b = cross(l[1] - l[0], s[1] - l[0]);
    return a * b < 0;
}

bool intersect(const Seg &p, const Seg &q) {
    bool pf = (ccw(p[0], p[1], q[0]) * ccw(p[0], p[1], q[1])) <= 0;
    bool qf = (ccw(q[0], q[1], p[0]) * ccw(q[0], q[1], p[1])) <= 0;
    return pf && qf;
}

bool intersect(const Line &l, const Point &p) {
    return is_same_line(p, l[0], l[1]);
}

bool intersect(const Seg &s, const Point &p) {
    value_type l1 = std::abs(s[0] - s[1]);
    value_type l2 = std::abs(s[0] - p);
    value_type l3 = std::abs(s[1] - p);
    return is_zero(l2 + l3 - l1);
}

value_type distance(const Point &p1, const Point &p2) {
    return std::abs(p1 - p2);
}

value_type distance(const Line &l, const Point &p) {
    return std::abs(p - proj(l, p));
}

value_type distance(const Line &p, const Line &q) {
    if (is_parallel(p, q)) return distance(p, q[0]);
    return 0;
}

value_type distance(const Line &l, const Seg &s) {
    if (intersect(l, s)) return 0;
    return std::min(distance(l, s[0]), distance(l, s[1]));
}

value_type distance(const Seg &s, const Point &p) {
    Line l(s[0], s[1]);
    Point pr = proj(l, p);
    if (intersect(s, pr)) return std::abs(pr - p);
    return std::min(std::abs(s[0] - p), std::abs(s[1] - p));
}

value_type distance(const Seg &p, const Seg &q) {
    if (intersect(p, q)) return 0;
    return var_min(distance(p, q[0]), distance(p, q[1]),
                   distance(q, p[0]), distance(q, p[1]));
}

int intersect(const Circle &c1, const Circle &c2) {
    if (c1.r < c2.r) return intersect(c2, c1);
    value_type d = distance(c1.p, c2.p);
    if (d + c2.r < c1.r) return 1;
    if (eq(d + c2.r, c1.r)) return 2;
    if (d < c1.r + c2.r) return 3;
    if (eq(c1.r - c2.r, d)) return 4;
    return 0;
}

std::pair<Point, Point> crosspoint(const Circle &c1, const Circle &c2) {
    value_type d = distance(c1.p, c2.p);
    value_type rc = cos(d, c1.r, c2.r) * c1.r;
    value_type rs = std::sqrt(c1.r * c1.r - rc * rc);
    auto unit_v = (c2.p - c1.p) / d;
    return std::make_pair(c1.p + unit_v * Point(rc, rs),
                          c1.p + unit_v * Point(rc, -rs));
}

}

int main() {
    ll a, b, h, m;
    std::cin >> a >> b >> h >> m;
    double argh = h / 12. + m / 12. / 60.;
    double argm = m / 60.;
    geo::Point hp = geo::rotate(geo::Point(0, a), 2 * geo::pi * (1. - argh));
    geo::Point mp = geo::rotate(geo::Point(0, b), 2 * geo::pi * (1. - argm));
    std::cout << geo::distance(hp, mp) << "\n";
    return 0;
}


Measured memory_bytes: 4208