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;
double t1, t2, d1, d2;
complex<double> cinema, home, shop;
void ReadData(complex<double> &a) {
  double x, y;
  scanf("%lf%lf", &x, &y);
  a = complex<double>(x, y);
}
double Dist(complex<double> x, complex<double> y) { return abs(x - y); }
bool cmp(pair<complex<double>, double> c1, pair<complex<double>, double> c2) {
  if (c1.first.real() < c2.first.real()) return true;
  if (c1.first.real() > c2.first.real()) return false;
  if (c1.first.imag() < c2.first.imag()) return true;
  if (c1.first.imag() > c2.first.imag()) return false;
  if (c1.second < c2.second) return true;
  return false;
}
bool InCircle(pair<complex<double>, double> c1,
              pair<complex<double>, double> c2) {
  double a = Dist(c1.first, c2.first) + c1.second;
  double b = c2.second;
  return a < b + eps;
}
bool IsInsect(pair<complex<double>, double> c1,
              pair<complex<double>, double> c2) {
  return Dist(c1.first, c2.first) < c1.second + c2.second + eps;
}
bool InPoint(complex<double> p, pair<complex<double>, double> c) {
  return Dist(p, c.first) < c.second + eps;
}
complex<double> GetNew(complex<double> e1, complex<double> e2,
                       complex<double> p, complex<double> c) {
  double a = c.real() - p.real();
  double b = c.imag() - p.imag();
  double x = a * e1.real() + b * e2.real();
  double y = a * e1.imag() + b * e2.imag();
  return complex<double>(x, y);
}
complex<double> GetOld(complex<double> e1, complex<double> e2,
                       complex<double> p, complex<double> c) {
  double a = c.real();
  double b = c.imag();
  double x = a * e1.real() + b * e1.imag();
  double y = a * e2.real() + b * e2.imag();
  x += p.real();
  y += p.imag();
  return complex<double>(x, y);
}
vector<complex<double> > GetInsect(pair<complex<double>, double> c1,
                                   pair<complex<double>, double> c2) {
  complex<double> p = c1.first;
  complex<double> e1 = c2.first - c1.first;
  e1 = e1 / abs(e1);
  complex<double> e2 = complex<double>(e1.imag(), -e1.real());
  complex<double> A = GetNew(e1, e2, p, c1.first);
  complex<double> B = GetNew(e1, e2, p, c2.first);
  double r1 = c1.second * c1.second;
  double r2 = c2.second * c2.second;
  double b = B.real();
  double x = (b * b + r1 - r2) / (2.0 * b);
  double y = r1 - x * x;
  if (y < 0.0) y = 0.0;
  vector<complex<double> > ret;
  if (y < eps)
    ret.push_back(complex<double>(x, y));
  else {
    ret.push_back(complex<double>(x, sqrt(y)));
    ret.push_back(complex<double>(x, -sqrt(y)));
  }
  for (int i = 0; i < (int)ret.size(); i++) ret[i] = GetOld(e1, e2, p, ret[i]);
  return ret;
}
bool Insect3Circles(vector<pair<complex<double>, double> > &circles) {
  sort(circles.begin(), circles.end(), cmp);
  do {
    if (!IsInsect(circles[0], circles[1])) return false;
    if (InCircle(circles[0], circles[1]))
      if (IsInsect(circles[0], circles[2]))
        return true;
      else
        return false;
  } while (next_permutation(circles.begin(), circles.end(), cmp));
  sort(circles.begin(), circles.end(), cmp);
  do {
    vector<complex<double> > pis = GetInsect(circles[0], circles[1]);
    bool flag = false;
    for (int i = 0; i < (int)pis.size(); i++)
      if (InPoint(pis[i], circles[2])) {
        flag = true;
        break;
      }
    if (flag) return true;
  } while (next_permutation(circles.begin(), circles.end(), cmp));
  return false;
}
bool check(double r) {
  vector<pair<complex<double>, double> > circles(3);
  circles[0] = pair<complex<double>, double>(cinema, r);
  circles[1] =
      pair<complex<double>, double>(shop, max(0.0, d1 - Dist(shop, home) - r));
  circles[2] = pair<complex<double>, double>(home, max(0.0, d2 - r));
  return Insect3Circles(circles);
}
int main() {
  cin >> t1 >> t2;
  ReadData(cinema);
  ReadData(home);
  ReadData(shop);
  d1 = t1 + Dist(cinema, shop) + Dist(shop, home);
  d2 = t2 + Dist(cinema, home);
  if (Dist(cinema, shop) + Dist(shop, home) < d2 + eps) {
    double ans = min(d1, d2);
    printf("%.9lf\n", ans);
    return 0;
  }
  double l = 0.0, r = min(d1, d2);
  for (int step = 0; step <= 40; step++) {
    double m = (l + r) / 2.0;
    if (check(m))
      l = m;
    else
      r = m;
  }
  double ans = (l + r) / 2.0;
  printf("%.9lf\n", ans);
  return 0;
}