#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;

const double PI = 3.14159265359;

struct gre {
    template<class T>
    bool operator()(T const &a, T const &b) const {
        return a > b;
    }
};

class Help {
public:
    vector<int> sieve;
    bool init = false;
    void initSieve() {
        if (init) {
            return;
        }
        sieve.resize(1e7 + 1);
        sieve[1] = 1;
        for (int i = 2; i < sieve.size(); i++) {
            if (sieve[i] == 0) {
                for (int j = i; j < sieve.size(); j += i) {
                    sieve[j] = i;
                }
            }
        }
        init = true;
    }
    int nextInt(int r) {
        return rand() % (r + 1);
    }
    int nextInt(int l, int r) {
        return nextInt(r - l) + l;
    }
    char nextLetter() {
        int ch = nextInt(25);
        return (char)('a' + ch);
    }
    char nextLetter(char ls, char rs) {
        int l = (int)(ls - 'a');
        int r = (int)(rs - 'a');
        int ch = nextInt(l, r);
        return (char)('a' + ch);
    }
    string nextWord(int len, char ls, char rs) {
        string s;
        for (int i = 0; i < len; i++) {
            s += nextLetter(ls, rs);
        }
        return s;
    }
    template<class T>
    void get(vector<T> &arr) {
        for (int i = 0; i < arr.size(); i++) {
            cin >> arr[i];
        }
    }
    template<class T>
    void get(vector<T> &arr, int start, int len) {
        for (int i = start; i < start + len; i++) {
            cin >> arr[i];
        }
    }
    template<class T>
    void display(vector<T> &arr) {
        for (T elem : arr) {
            cout << elem << ' ';
        }
        cout << '\n';
    }
    template<class T>
    void display(vector<T> &arr, string delim) {
        for (int i = 0; i < arr.size(); i++) {
            if (i > 0) {
                cout << delim;
            }
            cout << arr[i];
        }
        cout << '\n';
    }
    int lcm(int a, int b) {
        return (a * b) / __gcd(a, b);
    }
    vector<int> primeDivisors(int x) {
        initSieve();
        vector<int> primes;
        while (x > 1) {
            int sx = sieve[x];
            primes.push_back(sx);
            while (x % sx == 0) {
                x /= sx;
            }
        }
        return primes;
    }
    vector<int> divisors(int x) {
        vector<int> pd = primeDivisors(x);
        vector<int> div;
        queue<pair<int, int>> och;
        och.push({1, 0});
        while (!och.empty()) {
            pair<int, int> pr = och.front();
            och.pop();
            if (pr.second == pd.size()) {
                div.push_back(pr.first);
            } else {
                int curr = 1;
                while (x % curr == 0) {
                    och.push({pr.first * curr, pr.second + 1});
                    curr *= pd[pr.second];
                }
            }
        }
        return div;
    }
    void nextPermutation(vector<int> &arr) {
        int n = arr.size();
        for (int i = n - 2; i >= 0; i--) {
            if (arr[i] < arr[i + 1]) {
                int j = i + 1;
                for (int k = i + 2; k < n; k++) {
                    if (arr[k] > arr[i] && arr[k] < arr[j]) {
                        j = k;
                    }
                }
                swap(arr[i], arr[j]);
                sort(&(arr[i + 1]), &(arr[n - 1]) + 1);
                break;
            }
        }
    }
    void prevPermutation(vector<int> &arr) {
        int n = arr.size();
        for (int i = n - 2; i >= 0; i--) {
            if (arr[i] > arr[i + 1]) {
                int j = i + 1;
                for (int k = i + 2; k < n; k++) {
                    if (arr[k] < arr[i] && arr[k] > arr[j]) {
                        j = k;
                    }
                }
                swap(arr[i], arr[j]);
                sort(&(arr[i + 1]), &(arr[n - 1]) + 1, gre());
                break;
            }
        }
    }
    void buildPref(vector<int> &pref, vector<int> &arr) {
        pref[0] = arr[0];
        for (int i = 1; i < arr.size(); i++) {
            pref[i] = pref[i - 1] + arr[i];
        }
    }
    void buildSuff(vector<int> &suff, vector<int> &arr) {
        int n = arr.size();
        suff[n - 1] = arr[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            suff[i] = suff[i + 1] + arr[i];
        }
    }
    int divceil(int a, int b) {
        if (a == 0) {
            return 0;
        }
        return (a - 1) / b + 1;
    }
    int binpow(int a, int b, int m) {
        if (b == 0) {
            return 1;
        } else if (b == 1) {
            return a;
        } else if (b % 2 == 0) {
            int res = binpow(a, b / 2, m);
            return (res * res) % m;
        } else {
            return (a * binpow(a, b - 1, m)) % m;
        }
    }
    int modinv(int a, int m) {
        return binpow(a, m - 2, m);
    }
};

Help h;

void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double aang = 0;
    double bang = 0;
    for (int i = 0; i < 60 * h + m; i++) {
        aang += (2 * PI) / 720.0;
        bang += (2 * PI) / 60.0;
    }
    while (aang >= 2 * PI) {
        aang -= 2 * PI;
    }
    while (bang >= 2 * PI) {
        bang -= 2 * PI;
    }
    double diff = abs(aang - bang);
    double val = sqrt(a * a + b * b - 2 * a * b * cos(diff));
    cout << setprecision(11) << val << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    while (t--) {
        solve();
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 4144