#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

const double PI = 3.14159265359;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double aTheta = 2.0 * PI * (static_cast<double>(H * 60 + M) / (12.0 * 60.0));
    double bTheta = 2.0 * PI * (static_cast<double>(M) / 60.0);
    // cout << cos(aTheta) << ", " << sin(aTheta) << endl;
    // cout << cos(bTheta) << ", " << sin(bTheta) << endl;
    double x = static_cast<double>(A) * cos(aTheta) - static_cast<double>(B) * cos(bTheta);
    double y = static_cast<double>(A) * sin(aTheta) - static_cast<double>(B) * sin(bTheta);
    // cout << x << endl;
    // cout << y << endl;
    double pq2 = x * x + y * y;

    printf("%.10f\n", sqrt(pq2));
    // cout << sqrt(pq2) << endl;
    return 0;
}
