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;
const double pi = 2 * acos(0.0);
inline int cmp(double q, double w) {
  return (q < w + eps) ? (q > w - eps) ? 0 : -1 : 1;
}
struct point {
  double x, y;
  point(double x, double y) : x(x), y(y) {}
  point() { x = y = 0.0; }
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return q.x * x + q.y * y; }
  double operator%(point q) { return x * q.y - y * q.x; }
  int cmp(point q) const {
    if (int t = ::cmp(x, q.x)) return t;
    return ::cmp(y, q.y);
  }
  bool operator>(point q) const { return cmp(q) > 0; }
  bool operator<(point q) const { return cmp(q) < 0; }
  bool operator==(point q) const { return cmp(q) == 0; }
  bool operator>=(point q) const { return cmp(q) >= 0; }
  bool operator<=(point q) const { return cmp(q) <= 0; }
  bool operator!=(point q) const { return cmp(q) != 0; }
};
inline double abs(point p) { return sqrt(p.x * p.x + p.y * p.y); }
inline double dist(point a, point b) {
  return sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)));
}
vector<point> intersect_circles(point q, double r1, point w, double r2) {
  vector<point> res;
  double d = dist(q, w);
  if (cmp(d, r1 + r2) > 0 || cmp(d, fabs(r1 - r2)) < 0 || cmp(d, 0) == 0)
    return res;
  double a = (r1 * r1 + d * d - r2 * r2) / (2 * d);
  double c = (((r1 * r1 - a * a) < eps) ? 0 : sqrt(r1 * r1 - a * a));
  point b = (w - q) * (a / d);
  point n(w.y - q.y, q.x - w.x);
  n = n * (c / abs(n));
  res.push_back(q + b + n);
  res.push_back(q + b - n);
  return res;
}
int main() {
  double t1, t2;
  cin >> t1 >> t2;
  point C, H, S;
  cin >> C.x >> C.y;
  cin >> H.x >> H.y;
  cin >> S.x >> S.y;
  double max_t2 = dist(C, H) + t2;
  double max_t1 = dist(C, S) + dist(S, H) + t1;
  double b1 = 0;
  double b2 = min(max_t2, dist(C, S) + t1);
  for (int it = (0), _b(100); it < _b; ++it) {
    double rC = (b1 + b2) / 2;
    double rH = max_t2 - rC;
    double rS = dist(C, S) + t1 - rC;
    vector<point> a;
    a.push_back(C);
    a.push_back(H);
    a.push_back(S);
    vector<point> b = intersect_circles(C, rC, H, rH);
    for (int i = (0), _b(((int)b.size())); i < _b; ++i) a.push_back(b[i]);
    b = intersect_circles(C, rC, S, rS);
    for (int i = (0), _b(((int)b.size())); i < _b; ++i) a.push_back(b[i]);
    b = intersect_circles(S, rS, H, rH);
    for (int i = (0), _b(((int)b.size())); i < _b; ++i) a.push_back(b[i]);
    bool ok = false;
    for (int i = (0), _b(((int)a.size())); i < _b; ++i)
      if (cmp(dist(a[i], C), rC) <= 0 && cmp(dist(a[i], S), rS) <= 0 &&
          cmp(dist(a[i], H), rH) <= 0)
        ok = true;
    if (ok)
      b1 = rC;
    else
      b2 = rC;
  }
  double ans = (b1 + b2) / 2;
  if (cmp(dist(C, S) + dist(S, H), max_t2) <= 0) ans = min(max_t1, max_t2);
  printf("%.10lf\n", ans);
  return 0;
}