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;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 != vec.size()) os << " ";
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &st) {
  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    os << *itr;
    auto titr = itr;
    if (++titr != st.end()) os << " ";
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &st) {
  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    os << *itr;
    auto titr = itr;
    if (++titr != st.end()) os << " ";
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &st) {
  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    os << *itr;
    auto titr = itr;
    if (++titr != st.end()) os << " ";
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &st) {
  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    os << *itr;
    auto titr = itr;
    if (++titr != st.end()) os << " ";
  }
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    os << itr->first << ":" << itr->second;
    auto titr = itr;
    if (++titr != mp.end()) os << " ";
  }
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) {
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    os << itr->first << ":" << itr->second;
    auto titr = itr;
    if (++titr != mp.end()) os << " ";
  }
  return os;
}
using ll = long long int;
using P = pair<int, int>;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
struct fast_io {
  fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
  }
} fast_io_;
struct point2d {
  double x, y;
  point2d() {}
  point2d(double x, double y) : x(x), y(y) {}
  point2d operator+(const point2d &r) const {
    return point2d(x + r.x, y + r.y);
  }
  point2d operator-(const point2d &r) const {
    return point2d(x - r.x, y - r.y);
  }
  point2d &operator+=(const point2d &r) {
    *this = *this + r;
    return *this;
  }
  point2d &operator-=(const point2d &r) {
    *this = *this - r;
    return *this;
  }
  bool operator==(const point2d &r) const {
    return abs(x - r.x) < EPS && abs(y - r.y) < EPS;
  }
  bool operator!=(const point2d &r) const { return !(*this == r); }
  bool operator<(const point2d &r) const {
    if (abs(x - r.x) >= EPS) return x < r.x;
    return y < r.y;
  }
};
point2d operator*(double x, const point2d &p) {
  return point2d(x * p.x, x * p.y);
}
point2d operator/(const point2d &p, double x) {
  return point2d(p.x / x, p.y / x);
}
double norm(const point2d &a) { return sqrt(a.x * a.x + a.y * a.y); }
double dis(const point2d &a, const point2d &b) {
  point2d c = a - b;
  return norm(c);
}
double inner_product(const point2d &a, const point2d &b) {
  return a.x * b.x + a.y * b.y;
}
double outer_product(const point2d &a, const point2d &b) {
  return a.x * b.y - a.y * b.x;
}
double cosine(const point2d &a, const point2d &b) {
  return inner_product(a, b) / norm(a) / norm(b);
}
double cross(const point2d &o, const point2d &a, const point2d &b) {
  return outer_product(a - o, b - o);
}
point2d c, h, s;
double A, B, C;
double t1, t2;
double calc(double k) {
  point2d u = s + k * (h - s);
  if (dis(c, u) + dis(u, h) <= C + t1 + EPS &&
      dis(c, u) + dis(u, s) + B <= A + B + t2 + EPS) {
    double res = min(C + t1 - dis(u, h), A + B + t2 - dis(u, s) - B);
    return res;
  }
  double ld = 0., rd = 1.;
  for (int i_ = (0); i_ < (100); ++i_) {
    double md = (ld + rd) / 2.;
    point2d v = c + md * (u - c);
    if (dis(c, v) + dis(v, h) > C + t1 + EPS ||
        dis(c, v) + dis(v, s) + B > A + B + t2 + EPS) {
      rd = md;
    } else {
      ld = md;
    }
  }
  point2d v = c + ld * (u - c);
  return dis(c, v);
}
int main(int argc, char const *argv[]) {
  cin >> t2 >> t1;
  cin >> c.x >> c.y >> h.x >> h.y >> s.x >> s.y;
  A = dis(c, s), B = dis(s, h), C = dis(h, c);
  if (A + B <= C + t1) {
    double ans = min(C + t1, A + B + t2);
    cout << ans << endl;
    return 0;
  }
  double ld = 0., rd = 1.;
  for (int i_ = (0); i_ < (100); ++i_) {
    double l = (2 * ld + rd) / 3., r = (ld + 2. * rd) / 3.;
    if (calc(l) > calc(r))
      rd = r;
    else
      ld = l;
  }
  cout << calc(ld) << endl;
  return 0;
}