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;
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << " ]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long double INF = 1e100;
long double EPS = 1e-15;
inline bool eq(long double a, long double b) { return fabs(a - b) < EPS; }
inline bool lt(long double a, long double b) { return a + EPS < b; }
inline bool gt(long double a, long double b) { return a > b + EPS; }
inline bool le(long double a, long double b) { return lt(a, b) || eq(a, b); }
inline bool ge(long double a, long double b) { return gt(a, b) || eq(a, b); }
struct pt {
  long double x, y;
  pt() {}
  pt(long double x, long double y) : x(x), y(y) {}
  pt(const pt &p) : x(p.x), y(p.y) {}
  pt operator+(const pt &p) const { return pt(x + p.x, y + p.y); }
  pt operator-(const pt &p) const { return pt(x - p.x, y - p.y); }
  pt operator*(long double c) const { return pt(x * c, y * c); }
  pt operator/(long double c) const { return pt(x / c, y / c); }
  bool operator<(const pt &p) const {
    return lt(y, p.y) || (eq(y, p.y) && lt(x, p.x));
  }
  bool operator>(const pt &p) const { return p < pt(x, y); }
  bool operator<=(const pt &p) const { return !(pt(x, y) > p); }
  bool operator>=(const pt &p) const { return !(pt(x, y) < p); }
  bool operator==(const pt &p) const {
    return (pt(x, y) <= p) && (pt(x, y) >= p);
  }
};
long double dot(pt p, pt q) { return p.x * q.x + p.y * q.y; }
long double dist2(pt p, pt q) { return dot(p - q, p - q); }
long double dist(pt p, pt q) { return sqrtl(dist2(p, q)); }
long double norm2(pt p) { return dot(p, p); }
long double norm(pt p) { return sqrtl(norm2(p)); }
long double cross(pt p, pt q) { return p.x * q.y - p.y * q.x; }
ostream &operator<<(ostream &os, const pt &p) {
  return os << "(" << p.x << "," << p.y << ")";
}
istream &operator>>(istream &is, pt &p) { return is >> p.x >> p.y; }
int orient(pt a, pt b, pt c) {
  pt p = b - a, q = c - b;
  double cr = cross(p, q);
  if (eq(cr, 0)) return 0;
  if (lt(cr, 0)) return 1;
  return -1;
}
pt RotateCCW90(pt p) { return pt(-p.y, p.x); }
pt RotateCW90(pt p) { return pt(p.y, -p.x); }
pt RotateCCW(pt p, long double t) {
  return pt(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
pt ProjectPointLine(pt a, pt b, pt c) {
  return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a);
}
pt ProjectPointSegment(pt a, pt b, pt c) {
  long double r = dot(b - a, b - a);
  if (eq(r, 0)) return a;
  r = dot(c - a, b - a) / r;
  if (lt(r, 0)) return a;
  if (gt(r, 1)) return b;
  return a + (b - a) * r;
}
long double DistancePointSegment(pt a, pt b, pt c) {
  return sqrtl(dist2(c, ProjectPointSegment(a, b, c)));
}
long double DistancePointLine(pt a, pt b, pt c) {
  return sqrtl(dist2(c, ProjectPointLine(a, b, c)));
}
bool LinesParallel(pt a, pt b, pt c, pt d) {
  return eq(cross(b - a, c - d), 0);
}
bool LinesCollinear(pt a, pt b, pt c, pt d) {
  return LinesParallel(a, b, c, d) && eq(cross(a - b, a - c), 0) &&
         eq(cross(c - d, c - a), 0);
}
bool SegmentsIntersect(pt a, pt b, pt c, pt d) {
  if (LinesCollinear(a, b, c, d)) {
    if (eq(dist2(a, c), 0) || eq(dist2(a, d), 0) || eq(dist2(b, c), 0) ||
        eq(dist2(b, d), 0))
      return true;
    if (gt(dot(c - a, c - b), 0) && gt(dot(d - a, d - b), 0) &&
        gt(dot(c - b, d - b), 0))
      return false;
    return true;
  }
  if (gt(cross(d - a, b - a) * cross(c - a, b - a), 0)) return false;
  if (gt(cross(a - c, d - c) * cross(b - c, d - c), 0)) return false;
  return true;
}
pt ComputeLineIntersection(pt a, pt b, pt c, pt d) {
  b = b - a;
  d = c - d;
  c = c - a;
  assert(gt(dot(b, b), 0) && gt(dot(d, d), 0));
  return a + b * cross(c, d) / cross(b, d);
}
bool between(pt a, pt b, pt c) {
  if (!eq(cross(b - a, c - b), 0)) return 0;
  return le(dot(b - a, b - c), 0);
}
pt ComputeSegmentIntersection(pt a, pt b, pt c, pt d) {
  if (!SegmentsIntersect(a, b, c, d)) return {INF, INF};
  if (LinesCollinear(a, b, c, d)) {
    if (between(a, c, b)) return c;
    if (between(c, a, d)) return a;
    return b;
  }
  return ComputeLineIntersection(a, b, c, d);
}
pt ComputeCircleCenter(pt a, pt b, pt c) {
  b = (a + b) / 2;
  c = (a + c) / 2;
  return ComputeLineIntersection(b, b + RotateCW90(a - b), c,
                                 c + RotateCW90(a - c));
}
bool PointInPolygon(const vector<pt> &p, pt q) {
  int n = p.size(), windingNumber = 0;
  for (int i = 0; i < n; ++i) {
    if (eq(dist2(q, p[i]), 0)) return 1;
    int j = (i + 1) % n;
    if (eq(p[i].y, q.y) && eq(p[j].y, q.y)) {
      if (le(min(p[i].x, p[j].x), q.x) && le(q.x, max(p[i].x, p[j].x)))
        return 1;
    } else {
      bool below = lt(p[i].y, q.y);
      if (below != lt(p[j].y, q.y)) {
        auto orientation = orient(q, p[j], p[i]);
        if (orientation == 0) return 1;
        if (below == (orientation > 0)) windingNumber += below ? 1 : -1;
      }
    }
  }
  return windingNumber == 0 ? 0 : 1;
}
bool PointOnPolygon(const vector<pt> &p, pt q) {
  for (int i = 0; i < p.size(); i++)
    if (eq(dist2(ProjectPointSegment(p[i], p[(i + 1) % p.size()], q), q), 0))
      return true;
  return false;
}
long double ComputeSignedArea(const vector<pt> &p) {
  long double ans = 0;
  for (int i = 0; i < p.size(); i++) {
    int j = (i + 1) % p.size();
    ans += cross(p[i], p[j]);
  }
  return ans / 2.0;
}
long double ComputeArea(const vector<pt> &p) {
  return fabs(ComputeSignedArea(p));
}
vector<pt> CircleLineIntersection(pt a, pt b, pt c, long double r) {
  vector<pt> ret;
  b = b - a;
  a = a - c;
  long double A = dot(b, b), B = dot(a, b), C = dot(a, a) - r * r,
              D = B * B - A * C;
  if (lt(D, 0)) return ret;
  ret.push_back(c + a + b * (-B + sqrtl(D + EPS)) / A);
  if (gt(D, 0)) ret.push_back(c + a + b * (-B - sqrtl(D)) / A);
  return ret;
}
vector<pt> CircleCircleIntersection(pt a, pt b, long double r, long double R) {
  vector<pt> ret;
  long double d = sqrtl(dist2(a, b)), d1 = dist2(a, b);
  pt inf(INF, INF);
  if (eq(d1, 0) && eq(r, R)) {
    ret.push_back(inf);
    return ret;
  }
  if (gt(d, r + R) || lt(d + min(r, R), max(r, R))) return ret;
  long double x = (d * d - R * R + r * r) / (2 * d), y = sqrtl(r * r - x * x);
  pt v = (b - a) / d;
  ret.push_back(a + v * x + RotateCCW90(v) * y);
  if (gt(y, 0)) ret.push_back(a + v * x - RotateCCW90(v) * y);
  return ret;
}
pt ComputeCentroid(const vector<pt> &p) {
  pt c(0, 0), inf(INF, INF);
  long double scale = 6.0 * ComputeSignedArea(p);
  if (p.empty()) return inf;
  if (eq(scale, 0)) return inf;
  for (int i = 0; i < p.size(); i++) {
    int j = (i + 1) % p.size();
    c = c + (p[i] + p[j]) * cross(p[i], p[j]);
  }
  return c / scale;
}
bool IsSimple(const vector<pt> &p) {
  for (int i = 0; i < p.size(); i++) {
    for (int k = i + 1; k < p.size(); k++) {
      int j = (i + 1) % p.size();
      int l = (k + 1) % p.size();
      if (i == l || j == k) continue;
      if (SegmentsIntersect(p[i], p[j], p[k], p[l])) return false;
    }
  }
  return true;
}
bool pointinConvexPolygon(vector<pt> poly, pt point, int top) {
  if (point < poly[0] || point > poly[top]) return 0;
  auto orientation = orient(point, poly[top], poly[0]);
  if (orientation == 0) {
    if (point == poly[0] || point == poly[top]) return 1;
    return top == 1 || top + 1 == poly.size() ? 1 : 1;
  } else if (orientation < 0) {
    auto itRight = lower_bound(poly.begin() + 1, poly.begin() + top, point);
    return orient(itRight[0], point, itRight[-1]) <= 0;
  } else {
    auto itLeft = upper_bound(poly.rbegin(), poly.rend() - top - 1, point);
    return (orient(itLeft == poly.rbegin() ? poly[0] : itLeft[-1], point,
                   itLeft[0])) <= 0;
  }
}
long double maxDist2(vector<pt> poly) {
  int n = poly.size();
  long double res = 0;
  for (int i = 0, j = n < 2 ? 0 : 1; i < j; ++i)
    for (;; j = j + 1 % n) {
      res = max(res, dist2(poly[i], poly[j]));
      if (gt(cross(poly[j + 1 % n] - poly[j], poly[i + 1] - poly[i]), 0)) break;
    }
  return res;
}
long double DistancePointPlane(long double x, long double y, long double z,
                               long double a, long double b, long double c,
                               long double d) {
  return fabs(a * x + b * y + c * z - d) / sqrtl(a * a + b * b + c * c);
}
long double CircleCircleIntersectionArea(pt c1, long double r1, pt c2,
                                         long double r2) {
  if (lt(r1, r2)) swap(c1, c2), swap(r1, r2);
  long double d = dist2(c1, c2), d1 = dist(c1, c2);
  if (le(r1 + r2, d1)) return 0;
  if (ge(r1 - r2, d1)) return 4.0 * atan(1.0) * r2 * r2;
  long double alfa = acos((d + r1 * r1 - r2 * r2) / (2 * d1 * r1));
  long double beta = acos((d + r2 * r2 - r1 * r1) / (2 * d1 * r2));
  return alfa * r1 * r1 + beta * r2 * r2 - sin(2 * alfa) * r1 * r1 / 2 -
         sin(2 * beta) * r2 * r2 / 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(25);
  long long x1, y1, x2, y2, r1, r2;
  cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
  pt c1(x1, y1), c2(x2, y2);
  cout << CircleCircleIntersectionArea(c1, r1, c2, r2) << "\n";
}