/*****************************************************************************/
#define JaiShreeRam

/****************************************************************************/
/*

/************* आत्मनिर्भर ***************/

/*

TO NIGHT
--------------------------
BY - Percy Bysshe Shelley 
--------------------------
Swiftly walk o'er the western wave,
            Spirit of the Night!
Out of the misty eastern cave,
Where, all the long and lone daylight,
Thou wovest dreams of joy and fear,
Which make thee terrible and dear,—
            Swift be thy flight!

                       
Wrap thy form in a mantle gray,
            Star-inwrought!
Blind with thine hair the eyes of Day;
Kiss her until she be wearied out,
Then wander o'er city, and sea, and land,
Touching all with thine opiate wand—
            Come, long-sought!

                       
When I arose and saw the dawn,
            I sighed for thee;
When light rode high, and the dew was gone,
And noon lay heavy on flower and tree,
And the weary Day turned to his rest,
Lingering like an unloved guest,
            I sighed for thee.

                       
Thy brother Death came, and cried,
            Wouldst thou me?
Thy sweet child Sleep, the filmy-eyed,
Murmured like a noontide bee,
Shall I nestle near thy side?
Wouldst thou me?—And I replied,
            No, not thee!

                       
Death will come when thou art dead,
            Soon, too soon—
Sleep will come when thou art fled;
Of neither would I ask the boon
I ask of thee, belovèd Night—
Swift be thine approaching flight,
            Come soon, soon! 
**************************************************/

/*************************************************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

#define For(i, a, b) for (int i = a; i < b; i++)
#define Forl(i, size) for (int i = 0; i < size; i++)
#define Forr(i, size) for (int i = size - 1; i >= 0; i--)
#define ForR(i, a, b) for (int i = a; i >= b; i--)
#define s(n) scanf("%d", &n)
#define p(n) printf("%d\n", n)
#define ps(n) printf("%s\n", n)
#define cntd continue;
#define sd(n) \
    int n;    \
    scanf("%d", &n)
#define sl(n)        \
    long long int n; \
    scanf("%lld", &n)
#define pb(n) push_back(n)
#define contd continue;
#define clr(a) memset(a, 0, sizeof(a));
#define all(c) (c).begin(), (c).end()
#define len length()
#define size size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define ret return 0;
#define PI 3.141592653589793

#define ram(c, itr) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
#define sita(c, itr) for (__typeof((c).rbegin()) itr = (c).rbegin(); itr != (c).rend(); itr++)

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const long long Mod = 1e9 + 7;
const int N = 1e5 + 9;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<string> vst;
typedef vector<bool> vb;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

ll sum = 0, ans = 0, res = 0;

vector<string> vec_splitter(string s)
{
    s += ',';
    vector<string> res;
    while (!s.empty())
    {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args, __attribute__((unused)) int idx) { cerr << endl; }
void debug_out(
    vector<string> __attribute__((unused)) args,
    __attribute__((unused)) int idx,
    __attribute__((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define watch(x) cout << (#x) << " is " << (x) << endl;

#ifdef JaiShreeRam
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>>
{
    static_assert(D >= 1, "Vector dimension must be greater than zero!");
    template <typename... Args>
    Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...))
    {
    }
};
template <typename T>
struct Vec<1, T> : public vector<T>
{
    Vec(int n = 0, const T &val = T()) : vector<T>(n, val)
    {
    }
};

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b)
{
    if (a.se == b.se)
        return (a.fi < b.fi);

    return (a.se < b.se);
}

bool isPrime(ll num)
{
    bool flag = true;
    if (num == 1)
        return false;
    for (int i = 2; i <= sqrt(num); i++)
    {
        if (num % i == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
set<ull> fac;
void allFactors(ull n)
{
    for (ll i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            fac.insert(i);
            if (i != n / i)
            {
                fac.insert(n / i);
            }
        }
    }
}

ll findSum(ll a[], int l, int r)
{
    ll sum = 0;
    For(i, l, r)
    {
        sum += a[i];
    }
    return sum;
}

vector<pair<int, int>> vec1; //Prime Factors along with their exponents
void primeFactors(ll n)
{
    int c1 = 0;

    while (n % 2 == 0)
    {
        // printf("%d ", 2);
        n = n / 2;
        c1++;
    }
    if (c1)
        vec1.pb(mp(2, c1));
    c1 = 0;
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        c1 = 0;
        while (n % i == 0)
        {
            // printf("%d ", i);

            n = n / i;
            c1++;
        }
        if (c1)
            vec1.pb(mp(i, c1));
    }
    c1 = 0;
    if (n > 2)
        vec1.pb(mp(n, 1));
}

ll power(int x, unsigned int y)
{
    int temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ull nCr(ll n, ll r)
{
    ull p = 1;
    ull k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;
            ll m = __gcd(p, k);
            p /= m;
            k /= m; //Simplifying
            n--;
            r--;
        }
    }
    else
        p = 1;

    return p;
}

ll lcm(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}

unsigned int countBits(ll n, int specify)
{
    unsigned int count = 0, total = 0;
    if (n == 0)
    {
        if (specify == 1)
            return 0;
        else
            return 1;
    }
    while (n)
    {
        total += 1;
        count += n & 1;
        n >>= 1;
    }
    if (specify == 1)
        return count;
    else
        return (total - count);
}

//Seive of Eratosthenes

// const ll maxN = 1e7 + 9;
// vector<bool> pr((ll)1e7 + 9, true);
// vector<ll> pp;

// void seive()
// {
//     pr[0] = false;
//     pr[1] = false;
//     for (ll p = 2; p * p <= maxN; p++)
//     {
//         if (pr[p])
//         {
//             for (ll i = p * p; i <= maxN; i += p)
//             {
//                 pr[i] = false;
//             }
//         }
//     }
//     for (ll i = 0; i <= maxN; i++)
//     {
//         if (pr[i] == true)
//         {
//             // debug(i);
//             pp.pb(i);
//         }
//     }
// }

/**************************************************************************************************************

// Function and essential data structures For BFS In A Grid;

// int n, m, k;
// int c1 = 0;
// string s[509];
// int dr[] = {-1, 1, 0, 0};
// int dc[] = {0, 0, 1, -1};
// queue<int> rq, cq;
// bool vis[509][509] = {false};

// int cont = 0;
// void explore(int r, int c)
// {
//     int rr, cc;
//     for (int i = 0; i < 4; i++)
//     { // if(cont==c1-k)return;
//         rr = r + dr[i];
//         cc = c + dc[i];

//         if (rr < 0 || cc < 0)
//             continue;
//         if (rr >= n || cc >= m)
//             continue;

//         if (vis[rr][cc])
//             continue;
//         if (s[rr][cc] == '#')
//             continue;
//         rq.push(rr);
//         cq.push(cc);
//         cont++;
//         if (cont == (c1 - k))
//         {
//             return;
//         }
//         vis[rr][cc] = true;
//     }
// }

// void bfsInGrid(int sr, int sc)
// {

//     rq.push(sr);
//     cq.push(sc);
//     vis[sr][sc] = 1;
//     while (cont != (c1 - k))
//     {
//         // cont++;
//         int r = rq.front();
//         rq.pop();
//         int c = cq.front();
//         cq.pop();
//         explore(r, c);
//     }
// }


/************************************************************************************/

//  long long findTargetSumWays(vector<int>& vec, int S) {

//         long long sum=0;
//         for(int i=0;i<vec.size;i++)
//         {
//             sum+=vec[i];
//         }
//         // cout<<sum<<endl;
//         if(sum<S||(sum+S)%2!=0)return 0;
//         long long s1=(sum+S)/2;

//         long long dp[vec.size+10][s1+10]={0};
//         for(int j=0;j<s1+1;j++)
//         {
//             dp[0][j]=0;
//         }
//         for(int i=0;i<vec.size+1;i++)
//         {
//             dp[i][0]=1;
//         }
//         for(i=1;i<vec.size+1;i++)
//         {
//             For(j,0,s1+1)
//             {if(j>=vec[i-1])
//                 dp[i][j]=dp[i-1][j]+dp[i-1][j-vec[i-1]];
//                 else
//                 {
//                     dp[i][j]=dp[i-1][j];
//                 }

//             }
//         }
//         return dp[vec.size][s1];

//     }
/******************************************************************************************************************************************/
/*******************************************************************************************************************************************/
// #define SIZE 100009
// ll fact[SIZE] = {0};

// void factorial()
// {
//     int i;
//     fact[0] = 1;
//     for (i = 1; i <= SIZE; i++)
//     {

//         // Calculation of factorial
//         // As fact[i-1] stores the factorial of n-1
//         // so factorial of n is fact[i] = (fact[i-1]*i)
//         fact[i] = (fact[i - 1] * i) % Mod;
//     }
// }

void scar(ll a[], int n, int param = 0)
{
    if (param == 0)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
    }
}

/*******************************************************************************************************************************************/
ld angleClock(int hour, int minutes)
{
    long double hourAngle = (ld)((hour % 12) + minutes * (ld)1.0 / (ld)60) * (ld)30;
    long double minutesAngle = (ld)minutes * (ld)6;
    long double a = abs((ld)hourAngle - (ld)minutesAngle);
    long double b = (ld)360 - (ld)a;
    return a < b ? a : b;
}
signed main()
{
    // boost

    //seive();

    // TO Enable or Disable Debuuging Go To the Top;
    string aux1, aux2, aux3;

    ll T = 1;

    // cin>>T;

    For(ZA, 1, T + 1)
    {

        int f = 0, fl1 = 0, fl2 = 0, u = 0, v = 0, w = 0, c1 = 0, c2 = 0, cont = 0, cnt = 0, c3 = 0, auxi = 0, auxj = 0;
        ll mi = INT_MAX, le = 0;
        ll ma = INT_MIN, sol = 0;
       int a,b,h,m;
       cin>>a>>b>>h>>m;
    //    if(h==0&&m==0){cout<<"0\n";ret}
       ld x=angleClock(h,m);
    //    cout<<"x = "<<x<<endl;
       x=x*PI/180;
    //    debug(x);
        if(cos(x)==(-1)){cout<<a+b<<endl;ret}
// debug(cos(PI));
       ld ans=(ld)sqrt(((ld)a*a+(ld)b*b-(ld)2*(ld)a*(ld)b*cos(x)));
    //    debug(cos(x));
       cout<<setprecision(15)<<ans<<endl;
      
    }

    return 0;
}

//*********************** PAY ATTENTION **********************************//
/*


------------
Even If You PASS The PRETESTS, Don't Be HAPPY (Don't even SMILE)!!
Your solution might fail in SYSTEM TESTS..!!
.
.
. 
Surprise MADAFAKA !!
-------------


*/
//*************************************************************************//

Measured memory_bytes: 4140