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-11;
struct Vector {
  double x, y;
};
void read(Vector& v) { scanf("%lf%lf", &v.x, &v.y); }
Vector operator+(const Vector& a, const Vector& b) {
  return (Vector){a.x + b.x, a.y + b.y};
}
Vector operator-(const Vector& a, const Vector& b) {
  return (Vector){a.x - b.x, a.y - b.y};
}
Vector operator*(const Vector& a, const Vector& b) {
  return (Vector){a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x};
}
Vector operator*(double a, const Vector& b) {
  return (Vector){a * b.x, a * b.y};
}
double cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y - b.x; }
double abs(const Vector& a) { return sqrt(((a.x) * (a.x)) + ((a.y) * (a.y))); }
double dis(const Vector& a, const Vector& b) { return abs(a - b); }
double t, t2;
Vector o, p, p2;
bool inCircle(const Vector& p, const Vector& o, double r) {
  return dis(o, p) - r <= eps;
}
int judge(const Vector& o, double r, const Vector& o2, double r2) {
  double d = dis(o, o2);
  if (d + r2 - r <= eps || d + r - r2 <= eps)
    return 0;
  else if (r2 + r - d >= -eps)
    return 1;
  else
    return 2;
}
void get(const Vector& o, double r, const Vector& o2, double r2, Vector& p,
         Vector& p2) {
  Vector v = o2 - o;
  double d = abs(v);
  v.x /= d;
  v.y /= d;
  double co = (((r) * (r)) + ((d) * (d)) - ((r2) * (r2))) / (2 * r * d);
  if (co - 1 > -eps) co = 1;
  double si = sqrt(1 - ((co) * (co)));
  p = o + (Vector){co * r, si * r} * v;
  p2 = o + (Vector){co * r, -si * r} * v;
}
bool check(double s) {
  double d = t2 - s, d2 = t - s;
  int r = judge(o, s, p, d), r2 = judge(o, s, p2, d2), r3 = judge(p, d, p2, d2);
  if (!r && !r2 && !r3)
    return true;
  else if (r == 2 || r2 == 2 || r3 == 2)
    return false;
  else if ((!r || !r2 || !r3) && (r || r2 || r3))
    return true;
  Vector i, j;
  if (r) {
    get(o, s, p, d, i, j);
    if (inCircle(i, p2, d2) || inCircle(j, p2, d2)) return true;
  }
  if (r2) {
    get(o, s, p2, d2, i, j);
    if (inCircle(i, p, d) || inCircle(j, p, d)) return true;
  }
  if (r3) {
    get(p, d, p2, d2, i, j);
    if (inCircle(i, o, s) || inCircle(j, o, s)) return true;
  }
  return false;
}
int main() {
  scanf("%lf%lf", &t, &t2);
  read(o);
  read(p);
  read(p2);
  p = p - o;
  p2 = p2 - o;
  o = o - o;
  double tmp;
  if ((tmp = abs(p2) + dis(p, p2)) <= abs(p) + t2) {
    printf("%.8lf", min(t + tmp, t2 + abs(p)));
    return 0;
  }
  t += abs(p2);
  t2 += abs(p);
  double left = 0, mid, right = min(t2, t);
  for (int i = 30; i; --i) {
    mid = (left + right) * 0.5;
    if (check(mid))
      left = mid;
    else
      right = mid;
  }
  printf("%.8lf", mid);
  return 0;
}