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

Solution:
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
struct Point {
  double x, y;
  Point() {}
  Point(double x1, double y1) : x(x1), y(y1) {}
  Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
  Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
  Point operator*(const double &t) const { return Point(x * t, y * t); }
  double dist(Point p) {
    return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
  }
  Point rotate(double t) {
    double xx = x * cos(t) - y * sin(t);
    double yy = x * sin(t) + y * cos(t);
    return Point(xx, yy);
  }
};
struct Circle {
  Point cntr;
  double r;
  Circle() {}
  Circle(Point a, double b) : cntr(a), r(b) {}
  vector<Point> intersect(Circle u) {
    if (r < u.r) return u.intersect(*this);
    vector<Point> vp;
    double D = cntr.dist(u.cntr);
    Point v = (u.cntr - cntr) * (r / D);
    if (abs(D - r - u.r) < eps || abs(D + u.r - r) < eps)
      vp.push_back(cntr + v);
    else if (D > r - u.r && D < r + u.r) {
      double a = acos((r * r + D * D - u.r * u.r) / (2.0 * r * D));
      vp.push_back(cntr + v.rotate(a));
      vp.push_back(cntr + v.rotate(-a));
    } else if (D + u.r < r)
      vp.push_back(u.cntr);
    return vp;
  }
};
bool check(Circle a, Circle b, Circle c) {
  vector<Point> vp;
  if (a.r <= -eps || b.r <= -eps || c.r <= -eps) return false;
  a.r = max(a.r, 0.0);
  b.r = max(b.r, 0.0);
  c.r = max(c.r, 0.0);
  vp = a.intersect(b);
  for (int i = 0; i < int((vp).size()); i++)
    if (c.cntr.dist(vp[i]) <= c.r + eps) return true;
  vp = a.intersect(c);
  for (int i = 0; i < int((vp).size()); i++)
    if (b.cntr.dist(vp[i]) <= b.r + eps) return true;
  vp = b.intersect(c);
  for (int i = 0; i < int((vp).size()); i++)
    if (a.cntr.dist(vp[i]) <= a.r + eps) return true;
  return false;
}
int main() {
  double t1, t2;
  Point c, h, s;
  cin >> t1 >> t2;
  cin >> c.x >> c.y >> h.x >> h.y >> s.x >> s.y;
  if (c.dist(s) + s.dist(h) <= c.dist(h) + t2 + eps)
    printf("%.8f\n", min(c.dist(s) + s.dist(h) + t1, c.dist(h) + t2));
  else {
    double l = 0, r = min(c.dist(s) + s.dist(h) + t1, c.dist(h) + t2);
    while (r - l > eps) {
      double m = (l + r) / 2;
      if (check(Circle(c, m), Circle(s, s.dist(c) + t1 - m),
                Circle(h, h.dist(c) + t2 - m)))
        l = m;
      else
        r = m;
    }
    printf("%.8f\n", l);
  }
  return 0;
}