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 long double PI = 3.1415926535897932384;
const long double EPS = 0.000000000001;
long double dist(long double x1, long double y1, long double x2,
                 long double y2) {
  return sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
}
class Point2d {
 public:
  Point2d() {}
  Point2d(long double x, long double y) : X(x), Y(y) {}
  long double x() const { return X; }
  long double y() const { return Y; }
  long double norm() const { return sqrt(X * X + Y * Y); }
  void setCoords(long double x, long double y) {
    X = x;
    Y = y;
  }
  friend std::ostream& operator<<(std::ostream& s, const Point2d& p) {
    s << p.x() << " " << p.y();
    return s;
  }

 private:
  long double X;
  long double Y;
};
class Circle {
 public:
  Circle(long double R, Point2d& C) : r(R), c(C) {}
  Circle(long double R, long double X, long double Y) : r(R), c(X, Y) {}
  Point2d getC() const { return c; }
  long double getR() const { return r; }
  size_t intersect(const Circle& C2, Point2d& i1, Point2d& i2) {
    long double d = Point2d(c.x() - C2.c.x(), c.y() - C2.c.y()).norm();
    if (d > r + C2.r) {
      return 0;
    } else if (d == 0 && r == C2.r) {
      cout << setprecision(12) << PI * C2.r * C2.r << endl;
      exit(0);
      return 0;
    } else if (d + min(r, C2.r) <= max(r, C2.r) + EPS) {
      cout << setprecision(12) << PI * min(r, C2.r) * min(r, C2.r) << endl;
      exit(0);
      return 0;
    } else {
      long double a = (r * r - C2.r * C2.r + d * d) / (2.0 * d);
      long double h = sqrt(r * r - a * a);
      Point2d p2(c.x() + (a * (C2.c.x() - c.x())) / d,
                 c.y() + (a * (C2.c.y() - c.y())) / d);
      i1.setCoords(p2.x() + (h * (C2.c.y() - c.y()) / d),
                   p2.y() - (h * (C2.c.x() - c.x()) / d));
      i2.setCoords(p2.x() - (h * (C2.c.y() - c.y()) / d),
                   p2.y() + (h * (C2.c.x() - c.x()) / d));
      if (d == r + C2.r) return 1;
      return 2;
    }
  }
  friend std::ostream& operator<<(std::ostream& s, const Circle& C) {
    s << "Center: " << C.getC() << ", r = " << C.getR();
    return s;
  }

 private:
  long double r;
  Point2d c;
};
int main() {
  long double x1, y1, r1, x2, y2, r2;
  cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
  long double td = dist(x1, y1, x2, y2);
  if (td >= r1 + r2) {
    printf("%.12f\n", 0);
    return 0;
  }
  Circle c1(r1, x1, y1);
  Circle c2(r2, x2, y2);
  Point2d p1, p2;
  c1.intersect(c2, p1, p2);
  long double res = 0;
  Point2d v1(p1.x() - x1, p1.y() - y1);
  Point2d v2(x2 - x1, y2 - y1);
  long double ang = acos((td * td + r1 * r1 - r2 * r2) / (2 * td * r1));
  if (ang < 0) ang *= -1;
  res += ((ang) - (sin(ang) * cos(ang))) * r1 * r1;
  v1 = Point2d(p1.x() - x2, p1.y() - y2);
  v2 = Point2d(x1 - x2, y1 - y2);
  ang = acos((td * td + r2 * r2 - r1 * r1) / (2 * td * r2));
  if (ang < 0) ang *= -1;
  res += ((ang) - (sin(ang) * cos(ang))) * r2 * r2;
  cout << setprecision(12) << res << endl;
  return 0;
}