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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final static BigDecimal PI = new BigDecimal("3.141592653589793238462643383279502884197169399375105820974944592307816406286");

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double x1 = in.nextDouble(), y1 = in.nextDouble(), r1 = in.nextDouble();
            double x2 = in.nextDouble(), y2 = in.nextDouble(), r2 = in.nextDouble();
            if (r1 < r2) {
                double t = x1;
                x1 = x2;
                x2 = t;
                t = y1;
                y1 = y2;
                y2 = t;
                t = r1;
                r1 = r2;
                r2 = t;
            }
            double ans = 0;
            BigDecimal X1 = new BigDecimal(x1), Y1 = new BigDecimal(y1), R1 = new BigDecimal(r1);
            BigDecimal X2 = new BigDecimal(x2), Y2 = new BigDecimal(y2), R2 = new BigDecimal(r2);
            BigDecimal D = sqrt(X1.subtract(X2).multiply(X1.subtract(X2)).add(Y1.subtract(Y2).multiply(Y1.subtract(Y2))));
            if (D.compareTo(BigDecimal.valueOf(r1 + r2)) < 0) {
                if (D.compareTo(BigDecimal.valueOf(r1 - r2)) <= 0) {
                    ans = PI.doubleValue() * r2 * r2;
                } else {
                    MathContext mathContext = new MathContext(100);
                    BigDecimal C1 = R1.multiply(R1).add(D.multiply(D)).subtract(R2.multiply(R2)).divide(BigDecimal.valueOf(2).multiply(R1).multiply(D), mathContext);
                    BigDecimal C2 = R2.multiply(R2).add(D.multiply(D)).subtract(R1.multiply(R1)).divide(BigDecimal.valueOf(2).multiply(R2).multiply(D), mathContext);
                    BigDecimal A1 = acos(C1);
                    BigDecimal A2 = acos(C2);
                    ans = A1.multiply(R1).multiply(R1).add(A2.multiply(R2).multiply(R2)).subtract(R1.multiply(sin(A1)).multiply(D)).doubleValue();
                }
            }
            out.printf("%.20f\n", ans);
        }

        BigDecimal sqrt(BigDecimal y) {
            MathContext mathContext = new MathContext(100);
            if (y.doubleValue() < 1e-8) {
                return y;
            }
            BigDecimal x = y;
            for (int i = 0; i < 50; ++i) {
                x = x.subtract(x.multiply(x).subtract(y).divide(BigDecimal.valueOf(2).multiply(x), mathContext));
            }
            return x;
        }

        BigDecimal acos(BigDecimal y) {
            MathContext mathContext = new MathContext(100);
            BigDecimal x = BigDecimal.ZERO, hpi = PI.multiply(BigDecimal.valueOf(0.5), mathContext);
            for (int i = 0; i < 50; ++i) {
                x = x.subtract(sin(x).subtract(y).divide(cos(x), mathContext));
            }
            return hpi.subtract(x);
        }

        BigDecimal cos(BigDecimal y) {
            BigDecimal ret = BigDecimal.ZERO, x = y;
            MathContext mathContext = new MathContext(100);
            y = BigDecimal.ONE;
            for (int i = 0; i < 100; i += 2) {
                ret = ret.add(y);
                y = y.multiply(x.multiply(x).divide(BigDecimal.valueOf((-i - 1) * (i + 2)), mathContext));
            }
            return ret;
        }

        BigDecimal sin(BigDecimal y) {
            BigDecimal ret = BigDecimal.ZERO, x = y;
            MathContext mathContext = new MathContext(100);
            for (int i = 1; i < 100; i += 2) {
                ret = ret.add(y);
                y = y.multiply(x.multiply(x).divide(BigDecimal.valueOf((-i - 1) * (i + 2)), mathContext));
            }
            return ret;
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}