Problem: You are given two circles. Find the area of their intersection.

Input

The first line contains three integers x1, y1, r1 ( - 109 ≤ x1, y1 ≤ 109, 1 ≤ r1 ≤ 109) — the position of the center and the radius of the first circle.

The second line contains three integers x2, y2, r2 ( - 109 ≤ x2, y2 ≤ 109, 1 ≤ r2 ≤ 109) — the position of the center and the radius of the second circle.

Output

Print the area of the intersection of the circles. The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

Examples

Input

0 0 4
6 0 4


Output

7.25298806364175601379


Input

0 0 5
11 0 5


Output

0.00000000000000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
namespace Geometry {
const double PI = acos(-1.0);
const double eps = 1e-6;
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  return x > 0 ? 1 : -1;
}
struct Point {
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y){};
  bool operator==(const Point &b) const {
    return !sgn(x - b.x) && !sgn(y - b.y);
  }
  Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }
  Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }
  double operator^(const Point &b) const { return x * b.y - y * b.x; }
  double operator*(const Point &b) const { return x * b.x + y * b.y; }
  double dis(const Point &b) const {
    return (x - b.x) * (x - b.x) + (y - b.y) * (y - b.y);
  }
  void input() { scanf("%lf%lf", &x, &y); }
  double len() { return sqrt(x * x + y * y); }
  double len2() { return x * x + y * y; }
};
struct Line {
  Point st, ed;
  double len, ang;
  bool isSeg;
  Line(Point st = Point(), Point ed = Point(), double len = 0, double ang = 0,
       bool isSeg = 0)
      : st(st), ed(ed), len(len), ang(ang), isSeg(isSeg){};
  void input() {
    st.input(), ed.input();
    len = st.dis(ed);
    ang = atan2(ed.y - st.y, ed.x - st.x);
  }
  bool SegisCross(Line l1, Line l2) const {
    Point p1 = l1.st, p2 = l1.ed;
    Point q1 = l2.st, q2 = l2.ed;
    return min(p1.x, p2.x) <= max(q1.x, q2.x) &&
           min(q1.x, q2.x) <= max(p1.x, p2.x) &&
           min(p1.y, p2.y) <= max(q1.y, q2.y) &&
           min(q1.y, q2.y) <= max(p1.y, p2.y) &&
           ((p2 - p1) ^ (q1 - p1)) * ((p2 - p1) ^ (q2 - p1)) <= 0 &&
           ((q2 - q1) ^ (p1 - q2)) * ((q2 - q1) ^ (p2 - q2)) <= 0;
  };
  pair<Point, int> operator&&(const Line &b) const {
    Point res = st;
    if (sgn((st - ed) ^ (b.st - b.ed)) == 0) {
      if (sgn((b.st - st) ^ (b.ed - st)) == 0)
        return make_pair(res, 0);
      else
        return make_pair(res, 1);
    }
    if (!SegisCross(Line(st, ed), b)) return make_pair(res, 3);
    double t = ((st - b.st) ^ (b.st - b.ed)) / ((st - ed) ^ (b.st - b.ed));
    res = res + (ed - st) * t;
    return make_pair(res, 2);
  }
};
double dis(Point a, Point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
double dis1(Point a, Point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool SegInline(Line a, Line b) {
  return sgn((a.st - b.st) ^ (a.ed - b.st)) *
             sgn((a.st - b.ed) ^ (a.ed - b.ed)) <=
         0;
}
double Dot(Point A, Point B) { return A.x * B.x + A.y * B.y; }
double Cross(Point A, Point B) { return A.x * B.y - A.y * B.x; }
double Length(Point A) { return sqrt(Dot(A, A)); }
double Angle(Point A, Point B) {
  return acos(Dot(A, B) / Length(A) / Length(B));
}
double torad(double angle) { return angle / 180 * PI; }
double toangle(double rad) { return 180 / PI * rad; }
Point GetIntersection(Line x, Line y) {
  Point a = x.ed - x.st, b = y.ed - y.st, c = y.st - x.st;
  return y.st + b * ((c ^ a) / (a ^ b));
}
double Area(Point *p, int n) {
  double ans = 0;
  for (int i = 3; i <= n; i++) ans += (p[i] - p[1]) ^ (p[i - 1] - p[1]);
  return fabs(ans) / 2;
}
struct Polygon {
  int n;
  Point p[N];
  void input(int n) {
    this->n = n;
    for (int i = 1; i <= n; i++) p[i].input();
    p[n + 1] = p[1];
  }
  double getArea() {
    double ans = 0;
    for (int i = 3; i <= n; i++) {
      ans += (p[i] - p[1]) ^ (p[i - 1] - p[1]);
    }
    return fabs(ans) / 2;
  }
  double getCircumference() {
    double ans = 0;
    for (int i = 1, j = n; i <= n; j = i++) ans += (p[i] - p[j]).len();
    return ans;
  }
  struct cmp {
    Point p;
    cmp(const Point &p0) { p = p0; }
    bool operator()(const Point &p1, const Point &p2) {
      double tmp = Cross(p1 - p, p2 - p);
      if (tmp > 0) return 1;
      if (tmp == 0 && dis(p, p1) < dis(p, p2)) return 1;
      return 0;
    }
  };
  void hull() {
    Point s[N];
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (p[1].y > p[i].y || (p[1].y == p[i].y && p[1].x > p[i].x))
        swap(p[1], p[i]);
    }
    sort(p + 2, p + n + 1, cmp(p[1]));
    s[++cnt] = p[1];
    for (int i = 2; i <= n; i++) {
      while (cnt > 1 && Cross(s[cnt] - s[cnt - 1], p[i] - s[cnt]) <= 0) cnt--;
      s[++cnt] = p[i];
    }
    s[cnt + 1] = p[1];
  }
};
struct Circle {
  Point o;
  double r;
  Circle(Point o = Point(), double r = 0) : o(o), r(r){};
  void input() { o.input(), scanf("%lf", &r); }
  double S() const { return PI * r * r; }
  pair<Point, double> getCircle(Point a, Point b, Point c) {
    double B = (a.x * a.x + a.y * a.y) * (b.y - c.y) +
               (b.x * b.x + b.y * b.y) * (c.y - a.y) +
               (c.x * c.x + c.y * c.y) * (a.y - b.y);
    double A = a.x * (b.y - c.y) - a.y * (b.x - c.x) + b.x * c.y - c.x * b.y;
    double C = (a.x * a.x + a.y * a.y) * (c.x - b.x) +
               (b.x * b.x + b.y * b.y) * (a.x - c.x) +
               (c.x * c.x + c.y * c.y) * (b.x - a.x);
    double D = (a.x * a.x + a.y * a.y) * (c.x * b.y - b.x * c.y) +
               (b.x * b.x + b.y * b.y) * (a.x * c.y - c.x * a.y) +
               (c.x * c.x + c.y * c.y) * (b.x * a.y - a.x * b.y);
    double x = -B / (2 * A);
    double y = -C / (2 * A);
    double R = sqrt((B * B + C * C - 4 * A * D) / (4 * A * A));
    return make_pair(Point(x, y), R);
  }
  pair<pair<Point, Point>, int> getLineCircleIntersection(const Line &B) {
    Point p = B.st;
    Point v = B.ed - B.st;
    double a = v.x, b = p.x - o.x, c = v.y, d = p.y - o.y;
    double e = a * a + c * c, f = 2 * (a * b + c * d),
           g = b * b + d * d - r * r;
    double delta = f * f - 4 * e * g;
    if (sgn(delta) < 0) return make_pair(make_pair(o, o), 0);
    if (sgn(delta) == 0) {
      double t1 = -f / (2 * e);
      return make_pair(make_pair(p + v * t1, p + v * t1), 1);
    }
    double t1 = (-f - sqrt(delta)) / (2 * e), t2 = (-f + sqrt(delta)) / (2 * e);
    return make_pair(make_pair(p + v * t1, p + v * t2), 2);
  }
  double getCircleCircleArea(const Circle &b) const {
    double d = (o - b.o).len();
    if (sgn(d - r - b.r) >= 0) return 0;
    if (sgn(fabs(r - b.r) - d) >= 0) return sgn(r - b.r) > 0 ? b.S() : S();
    long double ang1 = acos(((long double)r * r + (long double)d * d -
                             (long double)b.r * b.r) /
                            ((long double)2 * r * d)) *
                       2;
    long double ang2 = acos(((long double)b.r * b.r + (long double)d * d -
                             (long double)r * r) /
                            ((long double)2 * b.r * d)) *
                       2;
    return (0.5 * ang1 * r * r - 0.5 * r * r * sin(ang1)) +
           (0.5 * ang2 * b.r * b.r - 0.5 * b.r * b.r * sin(ang2));
  }
};
};  // namespace Geometry
using namespace Geometry;
int main() {
  Circle a, b;
  a.input(), b.input();
  printf("%.10lf\n", a.getCircleCircleArea(b));
  return 0;
}