#ifndef DBG
//#define NDEBUG
#pragma GCC optimize("Ofast")
#pragma GCC target("popcnt")
#endif // DBG
#include <bits/stdc++.h>
using namespace std;

#define cn const
#define cauto cn auto
#define FOR(i, from, to) for (int i = (from); i <= int(to); ++i)
#define FORN(i, n) FOR(i, 0, (n) - 1)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define X F
#define Y S
#define CONT(c) begin(c), end(c)
#define ARR(a, sz) (a), ((a) + (sz))

using ll = long long;
using ull = unsigned long long;
using ulong = unsigned long;
using uint = unsigned;


//#undef DBG
#ifdef DBG
cn bool dbg = true;
#else
cn bool dbg = false;
#endif // DBG

#ifdef MY
cn bool my = true;
#else
cn bool my = false;
#endif // MY

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template<typename Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template<typename Key, typename Value>
using ordered_map = __gnu_pbds::tree<Key, Value, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
constexpr T sqr(const T& x)
{
    return x * x;
}

template<typename T>
bool rMin(T& v, const T& rval)
{
    if (rval < v) {
        v = rval;
        return true;
    }
    return false;
}

template<typename T>
bool rMax(T& v, const T& rval)
{
    if (v < rval) {
        v = rval;
        return true;
    }
    return false;
}

ll rd()
{
    ll x;
    cin >> x;
    assert(cin);
    return x;
}

template<int Modulo>
struct MOD {
    static cn int M = Modulo;
    uint x;
    constexpr MOD(int val = 0) : x(val) { assert(0 <= val && val < M); }

    constexpr MOD& operator +=(MOD r) {
        x += r.x;
        if (x >= M)
            x -= M;
        return *this;
    }
    friend constexpr MOD operator +(MOD l, MOD r) { return l += r; }

    constexpr MOD& operator *=(MOD r) {
        x = (ll(x) * r.x) % M;
        return *this;
    }
    friend constexpr MOD operator *(MOD l, MOD r) { return l *= r; }

    constexpr MOD& operator -=(MOD r) {
        x -= r.x;
        if (x >= M)
            x += M;
        return *this;
    }
    friend constexpr MOD operator -(MOD l, MOD r) { return l -= r; }

    friend constexpr MOD operator -(MOD a) {
        if (a.x)
            return M - a.x;
        return 0;
    }

    friend ostream& operator <<(ostream& os, MOD x) { return os << x.x; }
    friend constexpr bool operator ==(MOD l, MOD r) { return l.x == r.x; }
    friend constexpr bool operator <(MOD l, MOD r) { return l.x < r.x; }
};

namespace std {
template<int Modulo>
struct hash<MOD<Modulo>> {
    size_t operator ()(MOD<Modulo> a) const noexcept { return a.x; }
};
}

using Mersen32Mod = MOD<(1LL << 31) - 1>;
template<>
Mersen32Mod& Mersen32Mod::operator *=(Mersen32Mod r) {
    cauto mul = ll(x) * r.x;
    x = (mul >> 31) + (mul & M);
    if (x >= M)
        x -= M;
    return *this;
}

template<int M>
constexpr MOD<M> binpow(MOD<M> a, ll p)
{
    MOD<M> res = 1;
    while (p != 0) {
        if (p % 2)
            res *= a;
        a *= a;
        p /= 2;
    }
    return res;
}

struct DoubleHash {
    uint r1;
    Mersen32Mod r2;

    DoubleHash(int x = 0) {
        r1 = x;
        r2 = x;
    }
    DoubleHash(initializer_list<int> lst) {
        assert(lst.size() == 2);
        auto it = lst.begin();
        r1 = *it++;
        r2 = *it;
    }

    DoubleHash& operator +=(DoubleHash R) {
        r1 += R.r1;
        r2 += R.r2;
        return *this;
    }
    friend DoubleHash operator +(DoubleHash L, DoubleHash R) {
        return L += R;
    }

    DoubleHash& operator -=(DoubleHash R) {
        r1 -= R.r1;
        r2 -= R.r2;
        return *this;
    }
    friend DoubleHash operator -(DoubleHash L, DoubleHash R) {
        return L -= R;
    }

    DoubleHash& operator *=(DoubleHash R) {
        r1 *= R.r1;
        r2 *= R.r2;
        return *this;
    }
    friend DoubleHash operator *(DoubleHash L, DoubleHash R) {
        return L *= R;
    }

    friend bool operator ==(DoubleHash L, DoubleHash R) {
        return L.r1 == R.r1 && L.r2 == R.r2;
    }

    friend bool operator <(DoubleHash L, DoubleHash R) {
        return mp(L.r1, L.r2) < mp(R.r1, R.r2);
    }

    size_t hash() const {
        return r2.x;
    }
};

namespace std {
template<>
struct hash<DoubleHash> {
    auto operator ()(DoubleHash h) const noexcept { return h.hash(); }
};
}

//#include "limits.h"

using dd = long double;

cn dd pi = acos(dd(-1));

struct Vec {
    dd x, y;
    Vec rotate(dd ang) const {
        return {x * cos(ang) - y * sin(ang), y * cos(ang) + x * sin(ang)};
    }
};

dd dist(Vec A, Vec B)
{
    return sqrt(max(sqr(A.x - B.x) + sqr(A.y - B.y), dd(0)));
}

int main()
{
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    #define FILEIO(TASK) do { freopen(TASK".in", "r", stdin); freopen(TASK".out", "w", stdout); } while (false)
    //FILEIO("penguins");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#endif // MY
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    int t = h * 60 + m;
    Vec hv = {0, a}, mv = {0, b};
    hv = hv.rotate(-2 * pi * t / (12 * 60));
    mv = mv.rotate(-2 * pi * m / 60);
    cout << fixed << setprecision(12) << dist(hv, mv);
}




Measured memory_bytes: 3800