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:
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let eps = 1e-8;
const let Pi = acos(-1.0);

int sign(let x) { return x < -eps ? -1 : (x > eps ? 1 : 0); }

struct Point {
  let x, y;
  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
  friend let Cdot(Point a, Point b) {
    return a.x * b.x + a.y * b.y;
  }
  friend let Times(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
  }
  Point operator ~ ()  { return (Point) {x, -y}; }

  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }
  Point Rotate(let k) {
    return Rotate(sin(k), cos(k));
  }

  let dist() {
    return sqrt(x * x + y * y);
  }

  Point Rotate(Point v) {
    let z = v.dist();
    if (sign(z) == 0) return *this;
    return Rotate(v.y / z, v.x / z);
  }

  let Dist(Point a, Point b) { return (a - b).dist(); }
};

typedef Point Vec;

let AreaTriangle(let a, let b, let c) {
  return sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / 4;
}

struct Circle {
  Point o;
  let r;

  friend let AreaIntersection(Circle c1, Circle c2) {
    let d = (c2.o - c1.o).dist(), r1 = c1.r, r2 = c2.r;
    logger("%Lf %Lf %Lf\n", d, r1, r2);
    if (sign(d - (r1 + r2)) >= 0) // 外切、相离
      return 0;
    if (sign(d - r2 + r1) <= 0) // c2 内切、内含 c1
      return Pi * r1 * r1;
    if (sign(d + r2 - r1) <= 0) // c1 内切、内含 c2
      return Pi * r2 * r2;
    let x1 = (r1 * r1 - r2 * r2 + d * d) / (2 * d), x2 = d - x1,
        y = sqrt(r1 * r1 - x1 * x1);
    logger("%Lf %Lf %Lf\n", x1, x2, y);
    let area = r1 * r1 * atan2(y, x1) + r2 * r2 * atan2(y, x2) 
      - AreaTriangle(r1, r2, d) * 2;
    return area;
  }
};

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Circle ReadCircle() {
  Point p = ReadPoint();
  let k;
  scanf("%Lf", &k);
  return (Circle) {p, k};
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_7_I.in", "r", stdin);
//   freopen("CGL_7_I.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_7_I.log", "w", stderr);
// #endif
  Circle c1 = ReadCircle(), c2 = ReadCircle();
  printf("%.8Lf\n", AreaIntersection(c1, c2));
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_7_I CGL_7_I.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_7_I CGL_7_I.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_7_I < CGL_7_I.in > CGL_7_I.out
==================
}}} */