Problem: Write a program which prints the area of intersection between given circles $c1$ and $c2$.

Constraints

* $-10,000 \leq c1x, c1y, c2x, c2y \leq 10,000$
* $1 \leq c1r, c2r \leq 10,000$

Input

The input is given in the following format.

$c1x\; c1y\; c1r$
$c2x\; c2y\; c2r$


$c1x$, $c1y$ and $c1r$ represent the coordinate and radius of the first circle. $c2x$, $c2y$ and $c2r$ represent the coordinate and radius of the second circle. All input values are given in integers.

Output

Output the area in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Examples

Input

0 0 1
2 0 2


Output

1.40306643968573875104


Input

1 0 1
0 0 3


Output

3.14159265358979311600

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

// basis
namespace geometry {
    using real_number = long double;

    constexpr real_number EPS = 1e-8;
    const real_number PI = acos(-1);
}

// point
namespace geometry {
    class point : public std::complex< real_number > {
        public:
        point() = default;

        using std::complex< real_number >::complex;
        point(const complex< real_number > &c) : std::complex< real_number >::complex(c) {}

        real_number dot(const point &b) const {
            return real() * b.real() + imag() * b.imag();
        }
        real_number cross(const point &b) const {
            return real() * b.imag() - imag() * b.real();
        }
    };

    using points = std::vector< point >;
}

// polygon
namespace geometry {
    using polygon = std::vector< point >;
    using polygons = std::vector< polygon >;
}

// line
namespace geometry { 
    class line {
        public:
        point a, b;

        line() = default;
        line(point a, point b) : a(a), b(b) {}

        line(real_number A, real_number B, real_number C) { // Ax + By = C
            if (fabs(A) < EPS) a = point(0, C / B), b = point(1, C / B);
            else if (fabs(B) < EPS) b = point(C / A, 0), b = point(C / A, 1);
            else a = point(0, C / B), b = point(C / A, 0);
        }
    };

    using lines = std::vector< line >;
}

// segment
namespace geometry {
    class segment : public line {
        segment() = default;

        using line::line;
    };

    using segments = std::vector< segment >;
}

// circle
namespace geometry {
    class circle {
        public:
        using radius = real_number;
        point p;
        radius r;

        circle(point p, radius r) : p(p), r(r) {}
    };

    using circles = std::vector< circle >;
}

// angle
namespace geometry {
    real_number get_angle(const point &a, const point &b, const point &c) {
        const point v(b - a), w(c - b);
        real_number alpha = std::atan2(v.imag(), v.real());
        real_number beta  = std::atan2(w.imag(), w.real());
        if (alpha > beta) std::swap(alpha, beta);
        real_number theta = (beta - alpha);
        return std::min(theta, 2 * PI - theta);
    }
}

namespace geometry {
    int ccw(const point &a, const point &b, const point &c) {
        const point v(b - a), w(c - a);
        if (v.cross(w) > EPS) return +1;
        if (v.cross(w) < -EPS) return -1;
        if (v.dot(w) < 0) return +2;
        if (norm(v) < norm(w)) return -2;
        return 0;
    }
}

namespace geometry {
    point projection(const line &l, const point &p) {
        real_number t = point(p - l.a).dot(point(l.a - l.b)) / norm(l.a - l.b);
        return point(l.a + (l.a - l.b) * t);
    }

    point projection(const segment &s, const point &p) {
        real_number t = point(p - s.a).dot(point(s.a - s.b)) / norm(s.a - s.b);
        return point(s.a + (s.a - s.b) * t);
    }
}

namespace geometry {
    // a-b-c
    line angle_bisector(const point &a, const point &b, const point &c) {
        const point v(a - b), w(c - b);
        const point p((a * abs(w) + c * abs(v)) / (abs(w) + abs(v)));
        return line(b, p);
    }
}

namespace geometry {
    bool is_intersect(const segment &s, const point &p) {
        return ccw(s.a, s.b, p) == 0;
    }

    // 共通接線の本数
    int intersect(circle c1, circle c2) { 
        if (c1.r < c2.r) std::swap(c1, c2);
        real_number d = abs(c1.p - c2.p);
        if (c1.r + c2.r < d) return 4;
        if (abs(c1.r + c2.r - d) < EPS) return 3;
        if (c1.r - c2.r < d) return 2;
        if (abs(c1.r - c2.r - d) < EPS) return 1;
        return 0;
    }
}

namespace geometry {
    real_number distance(const segment &s, const point &p) {
        point r = projection(s, p);
        if (is_intersect(s, r)) return abs(r - p);
        return std::min(abs(s.a - p), abs(s.b - p));
    }

    real_number distance(const point &p1, const point &p2) {
        return abs(p1 - p2);
    }
}

namespace geometry {
    point cross_point(const line &s, const line &t) {
        real_number a = point(s.b - s.a).cross(point(t.b - t.a));
        real_number b = point(s.b - s.a).cross(point(s.b - t.a));
        if (fabs(a) < EPS && fabs(b) < EPS) return t.a;
        return point(t.a + (t.b - t.a) * b / a);
    }

    std::pair< point, point > cross_point(const circle &a, const circle &b) {
        real_number d = abs(a.p - b.p);
        real_number s = acos((a.r * a.r + d * d - b.r * b.r) / (2 * a.r * d));
        real_number t = atan2(b.p.imag() - a.p.imag(), b.p.real() - a.p.real());
        point p1(a.p + point(cos(t + s) * a.r, sin(t + s) * a.r));
        point p2(a.p + point(cos(t - s) * a.r, sin(t - s) * a.r));
        return {p1, p2};
    }
}

namespace geometry {
    real_number area(const polygon &p) {
        real_number res = 0;
        for (int i = 0; i < p.size(); ++i) {
            res += p[i].cross(p[(i + 1) % p.size()]);
        }
        return res / real_number(2);
    }

    real_number area(circle a, circle b) {
        real_number d = abs(a.p - b.p);
        
        if (a.r + b.r <= d + EPS) return 0;
        if (d <= fabs(a.r - b.r)) {
            real_number r = std::min(a.r, b.r);
            return r * r * PI;
        }

        real_number res = 0;
        for (int i = 0; i < 2; ++i) {
            real_number alpha = acos((b.r * b.r + d * d - a.r * a.r) / (2 * b.r * d));
            real_number s = alpha * b.r * b.r;
            real_number t = b.r * b.r * sin(alpha) * cos(alpha);
            res += s - t;
            std::swap(a, b);
        }

        return res;
    }
            
}

namespace geometry {
    circle inscribed_circle(const point &a, const point &b, const point &c) {
        real_number A = abs(b - c), B = abs(c - a), C = abs(a - b);
        point x((a * A + b * B + c * C) / (A + B + C));
        real_number r = distance(segment(a, b), x);
        return circle(x, r); 
    }

    circle circumscribed_circle(const point &a, const point &b, const point &c) {
        point m1((a + b) / real_number(2)), m2((b + c) / real_number(2));
        point v((b - a).imag(), (a - b).real()), w((b - c).imag(), (c - b).real()); 
        line s(m1, point(m1 + v)), t(m2, point(m2 + w));

        point x = cross_point(s, t);
        return circle(x, distance(a, x));
    }
}

using namespace std;
using namespace geometry;

int main() {
    real_number c1x, c1y, c1r;
    real_number c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r;
    cin >> c2x >> c2y >> c2r;

    circle c1(point(c1x, c1y), c1r);
    circle c2(point(c2x, c2y), c2r);

    cout << fixed << setprecision(20);
    cout << area(c1, c2) << endl;
}