Problem: Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. 

Once they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it.

Bob wants to get home, but Alan has to go to the shop first, and only then go home. So, they agreed to cover some distance together discussing the film (their common path might pass through the shop, or they might walk circles around the cinema together), and then to part each other's company and go each his own way. After they part, they will start thinking about their daily pursuits; and even if they meet again, they won't be able to go on with the discussion. Thus, Bob's path will be a continuous curve, having the cinema and the house as its ends. Alan's path — a continuous curve, going through the shop, and having the cinema and the house as its ends.

The film ended late, that's why the whole distance covered by Alan should not differ from the shortest one by more than t1, and the distance covered by Bob should not differ from the shortest one by more than t2.

Find the maximum distance that Alan and Bob will cover together, discussing the film.

Input

The first line contains two integers: t1, t2 (0 ≤ t1, t2 ≤ 100). The second line contains the cinema's coordinates, the third one — the house's, and the last line — the shop's. 

All the coordinates are given in meters, are integer, and do not exceed 100 in absolute magnitude. No two given places are in the same building.

Output

In the only line output one number — the maximum distance that Alan and Bob will cover together, discussing the film. Output the answer accurate to not less than 4 decimal places.

Examples

Input

0 2
0 0
4 0
-3 0


Output

1.0000000000


Input

0 0
0 0
2 0
1 0


Output

2.0000000000

Solution (in JAVA):

Solution:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Problem_8D {
  final static double err = 1e-12;
  final static double bound = 1e2;

  static class Point {
    double x, y;

    Point(double x, double y) {
      this.x = x;
      this.y = y;
    }

    static double distance(Point p, Point q) {
      return Math.sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y));
    }

    Point perpendicular(Line l) {
      return Line.intersection(l, new Line(l.b, -l.a, l.a * y - l.b * x));
    }

    double distance(Line l) {
      return Math.abs(l.a * x + l.b * y + l.c) / Math.sqrt(l.a * l.a + l.b * l.b);
    }

    boolean insideOf(Circle c) {
      return distance(this, c.o) <= c.r;
    }
  }

  static class Line {
    double a, b, c;

    Line(double a, double b, double c) {
      this.a = a;
      this.b = b;
      this.c = c;
    }

    static Point intersection(Line m, Line n) {
      return new Point((m.c * n.b - m.b * n.c) / (m.b * n.a - m.a * n.b), (m.a * n.c - m.c * n.a)
          / (m.b * n.a - m.a * n.b));
    }

    Point[] intersection(Circle c) {
      if (doubleEquals(c.o.distance(this), c.r)) {
        return new Point[] {c.o.perpendicular(this)};
      } else if (c.o.distance(this) > c.r) {
        return null;
      } else {
        Point ppd = c.o.perpendicular(this);
        double dis = Math.sqrt(c.r * c.r - c.o.distance(this) * c.o.distance(this));
        Point[] ans = new Point[2];
        for (int i = -1; i <= 1; i += 2) {
          ans[(i + 1) / 2] =
              new Point(ppd.x + b * dis * i / Math.sqrt(a * a + b * b), ppd.y - a * dis * i
                  / Math.sqrt(a * a + b * b));
        }
        return ans;
      }
    }
  }

  static class Circle {
    Point o;
    double r;

    Circle(double x, double y, double r) {
      this.o = new Point(x, y);
      this.r = r;
    }

    Circle(Point o, double r) {
      this.o = new Point(o.x, o.y);
      this.r = r;
    }

    boolean insideOf(Circle c) {
      return Point.distance(o, c.o) + r < c.r;
    }

    static Line radicalAxis(Circle c1, Circle c2) {
      return new Line(c2.o.x - c1.o.x, c2.o.y - c1.o.y, (c1.o.x * c1.o.x + c1.o.y * c1.o.y - c2.o.x
          * c2.o.x - c2.o.y * c2.o.y + c2.r * c2.r - c1.r * c1.r) / 2);
    }

    static Point[] intersection(Circle c1, Circle c2) {
      return radicalAxis(c1, c2).intersection(c1);
    }
  }

  static boolean doubleEquals(double x, double y) {
    return Math.abs(x - y) < err;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double t1 = sc.nextDouble();
    double t2 = sc.nextDouble();
    Point cinema = new Point(sc.nextDouble(), sc.nextDouble());
    Point house = new Point(sc.nextDouble(), sc.nextDouble());
    Point shop = new Point(sc.nextDouble(), sc.nextDouble());
    double ch = Point.distance(cinema, house);
    double cs = Point.distance(cinema, shop);
    double hs = Point.distance(house, shop);
    if (cs + hs <= ch + t2) {
      System.out.printf("%.5f\n", Math.min(cs + hs + t1, ch + t2));
    } else {
      double l = 0.0;
      double r = Math.min(cs + t1, ch + t2);
      while (!doubleEquals(l, r)) {
        double m = (l + r) / 2;
        Circle[] c =
            new Circle[] {new Circle(shop, cs + t1 - m), new Circle(house, ch + t2 - m),
                new Circle(cinema, m)};
        Arrays.sort(c, new Comparator<Circle>() {
          public int compare(Circle c1, Circle c2) {
            return (int) Math.signum(c1.r - c2.r);
          }
        });
        boolean ok = false;
        for (int i = 0; i < 3 && !ok; i++) {
          Point[] p = Circle.intersection(c[i], c[(i + 1) % 3]);
          for (int j = 0; p != null && j < p.length; j++) {
            if (p[j].insideOf(c[(i + 2) % 3])) {
              ok = true;
            }
          }
        }
        if (ok || (c[0].insideOf(c[1]) && c[0].insideOf(c[2]))) {
          l = m;
        } else {
          r = m;
        }
      }
      System.out.printf("%.5f\n", l);
    }
    sc.close();
  }
}