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

using ll = long long int;
using llu = unsigned long long int;
using ld = long double;
const long long int NUM = 1000000;
const long double PI = 2*acos(0.0);
const long long int M = 1e9 + 7;
const long long int INF = LLONG_MAX;
const long long int maximum = LLONG_MIN;
#define parity(x)           __builtin_parityll(x)
#define lead_zero(x)        __builtin_clzll(x)
#define trail_zero(x)       __builtin_ctzll(x)
#define total_1s(x)         __builtin_popcountll(x)
#define first_1(x)          __builtin_ffsll(x)
#define log2_(x)            64 - __builtin_clzll(x) - 1
#define isLeap(x)           ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define LCM(a,b)            (a / __gcd(a,b)) * b
#define GCD(a,b)            __gcd(a,b)
#define dist(x1,y1,x2,y2)   sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define sqr(a)              ((a)*(a))
#define fast                ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define precision(a)        fixed<<setprecision(a)
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define REP(i,b)            for(long long int i = 0; i < b; i++)
#define READ(f)             freopen("f", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

/*void sieve(ll n) {
    bool status[(n>>1)+1] = {false};
    ll inc, i;
    for(i = 3; i*i <= n; i += 2)
    {
        if(!status[i>>1])
        {
            inc = i<<1;
            for(ll j = i*i; j <= n; j += inc)
                status[j>>1] = true;
        }
    }
}*/

/*ll power (ll a, ll b, ll m) {
    ll p = 1;
    while (b > 0) {
        a %= m;
        if (b & 1) {
            p = (p * a) % m;
        }
        a = sqr(a);
        b >>= 1;
    }
    return p;
}*/

/*ll binomialCoeffUtil(ll n, ll k, ll** dp)
{
	if (dp[n][k] != -1)
		return dp[n][k];

	if (k == 0) {
		dp[n][k] = 1;
		return dp[n][k];
	}

	if (k == n) {
		dp[n][k] = 1;
		return dp[n][k];
	}

	dp[n][k] = binomialCoeffUtil(n - 1, k - 1, dp) +
			binomialCoeffUtil(n - 1, k, dp);
	return dp[n][k];
}

ll binomialCoeff(ll n, ll k)
{
	ll** dp;
	dp = new ll*[n + 1];

	for (ll i = 0; i < (n + 1); i++) {
		dp[i] = new ll[k + 1];
	}

	for (ll i = 0; i < (n + 1); i++) {
		for (int j = 0; j < (k + 1); j++) {
			dp[i][j] = -1;
		}
	}

	return binomialCoeffUtil(n, k, dp);
}*/

/*bool compare(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.ff == b.ff)
        return a.ss <= b.ss;
    return a.ff < b.ff;
}*/

/* Direction arrays */
/* ll dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; */                        // 4 Direction
/* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */   // 8 Direction
/* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */            // Hexagonal Direction
/* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */            // Hexagonal Direction
/* ll day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */


//map<char, ll> m = { {'q', 9}, {'r', 5}, {'b', 3}, {'n', 3}, {'p', 1}, {'k', 0}, {'.', 0} };

//||\

int main() {
    fast;
    ld a, b, h, m;
    cout << precision(10);
    cin >> a >> b >> h >> m;
    h = (h*30.0) + (m/2.0);
    m *= 6.0;
    ld dif = fabs(h - m);
    if (dif > 180.0) dif = 360.0 - dif;
    ld rad = (PI*dif)/180.0;
    ld r = sqr(a) + sqr(b) - (2.0*a*b*cos(rad));
    r = sqrt(r);
    cout << r;
    return 0;
}


Measured memory_bytes: 4184