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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.StringTokenizer;

// Educational Codeforces Round 2
// Area of Two Circles' Intersection
public class Problem_600_D {


  public static void main(String[] args)
  {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    PrintWriter out = new PrintWriter(outputStream);
    Problem_600_D solver = new Problem_600_D();
    solver.solve(1, new InputStreamReader(inputStream), out);
    out.close();
  }

  public double areaCircleInter(long r1, long r2, long d2)
  {
    double d = Math.sqrt(d2);
    if(d == 0)return Math.PI*Math.min(r1,r2)*Math.min(r1,r2);
    if(d >= r1 + r2){
      return 0;
    }else if(d >= Math.abs(r1-r2)){
      BigDecimal bd = sqrt(d2);
      double o1 = f(r1*r1+d2-r2*r2, 2*r1, d, bd);
      double o2 = f(r2*r2+d2-r1*r1, 2*r2, d, bd);
      return 
          o1*r1*r1 +
          o2*r2*r2;
      //        return t1*r1*r1+t2*r2*r2-r1*r1/2*Math.sin(2*t1)-r2*r2/2*Math.sin(2*t2);
    }else{
      double r = Math.min(r1, r2);
      return Math.PI*r*r;
    }
  }

  BigDecimal sqrt(long x)
  {
    BigDecimal X = BigDecimal.valueOf(x);
    BigDecimal S = X;
    MathContext mc = new MathContext(100);
    for(int rep = 0;rep < 100;rep++){
      S = S.subtract(S.multiply(S, mc).subtract(X).divide(BigDecimal.valueOf(2).multiply(S), mc));
    }
    return S;
  }

  double f(long num, long den, double d, BigDecimal bd)
  {
    double eps = 1E-6;
    if(1-(double)num/den/d < eps){
      MathContext mc = new MathContext(100);
      double val = BigDecimal.ONE.subtract(BigDecimal.valueOf(num).divide(BigDecimal.valueOf(den), mc).divide(bd, mc)).doubleValue();
      double ret = 0;
      //        ret -= 3*Math.pow(num/den, 3.5)/64/Math.sqrt(2);
      //        ret -= 5*Math.pow(num/den, 3.5)/448/Math.sqrt(2);
      ret += Math.sqrt(2)*Math.pow(val, 2.5)/5;
      ret += 4./3*Math.sqrt(2)*Math.pow(val, 1.5);
      //        tr(num, den);
      return ret;
    }else{
      double u = (double)num/den/d;
      if(u < -1)u = -1;
      if(u > 1)u = 1;
      double a = Math.acos(u);
      return a-u*Math.sqrt(1-u*u);
    }
  }

  public void solve(int test, Reader input, PrintWriter out)
  {
    MyScanner in = new MyScanner(input);

    long x1 = in.nextLong();
    long y1 = in.nextLong();
    long r1 = in.nextLong();

    long x2 = in.nextLong();
    long y2 = in.nextLong();
    long r2 = in.nextLong();

    double area = areaCircleInter(r1, r2, (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    out.println(String.format("%.14f", area));
  }

  //-----------MyScanner class for faster input----------
  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner(Reader reader) {
      br = new BufferedReader(reader);
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    int[] nextIntArray(int n)
    {
      int[] r = new int[n];
      for(int i = 0; i < n; i++)
        r[i] = nextInt();
      return r;
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine(){
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }
  //--------------------------------------------------------

}