#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pr pair<int, int>
#define v1d vector<int>
#define mp make_pair
#define pb push_back
#define v1p vector<pr>
#define vb vector<bool>
#define v2d vector<vector<int>>
#define ff first
#define ss second
#define ld long double
#define all(v) v.begin(), v.end()
#define S(v) sort(v.begin(), v.end())
#define RS(v) sort(v.rbegin(), v.rend())
#define eb emplace_back
#define endl "\n"
#define MOD 1000000007
#define pi 3.14159265358
#define pqx priority_queue <int>
#define pqn priority_queue <int, v1d, greater<int> >
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int32_t main() {
    fio
    ld a, b, c, d;
    cin >> a >> b >> c >> d;
    // int h = d;
    if(a > b) swap(a, b);
    ld am = d * 6; 
    ld ah = c * 30;
    ah += d / 2;
    ld df = fabsl(ah - am);
    df = min(df, (ld)360 - df);
    df = min(df, (ld)180 - df);
    df = ((ld)pi / 180ll) * df;
    ld x = a * cos(df);
    ld y = a * sin(df);
    b -= x;
    ld ans = (b * b) + (y * y);
    ans = sqrt(ans);
    cout << setprecision(12) << ans;

}