import std;

alias P = Tuple!(double, "x", double, "y");

double radians(double deg) {
    return PI * deg / 180.0;
}

P rotate(P p, double degree) {
    auto rad = radians(degree);
    auto x = p.x * cos(rad) - p.y * sin(rad);
    auto y = p.x * sin(rad) + p.y * cos(rad);
    return P(x, y);
}

double calc(double a, double b, double h, double m) {
    auto s = rotate(P(0, a), (360 * h / 12.0) + (360 * m / 12.0 / 60.0));
    auto t = rotate(P(0, b), (360 * m / 60.0));
    return sqrt((s.x - t.x) ^^ 2 + (s.y - t.y) ^^ 2);
}

void main() {
    int a, b, h, m; scan(a, b, h, m);
    writefln("%.20f", calc(a, b, h, m));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;
