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;
struct point {
  double x, y;
  point(double x, double y) : x(x), y(y) {}
  point() {}
  inline void read() { scanf("%lf%lf", &x, &y); }
  inline double len() const { return sqrt(x * x + y * y); }
  inline double len2() const { return x * x + y * y; }
};
inline int sgn(double a) {
  if (a > 1e-8)
    return 1;
  else if (a < -1e-8)
    return -1;
  return 0;
}
inline point operator-(const point &a, const point &b) {
  return point(a.x - b.x, a.y - b.y);
}
inline point operator+(const point &a, const point &b) {
  return point(a.x + b.x, a.y + b.y);
}
inline point operator*(const point &a, double b) {
  return point(b * a.x, b * a.y);
}
inline point operator*(double b, const point &a) {
  return point(b * a.x, b * a.y);
}
inline double operator*(const point &a, const point &b) {
  return a.x * b.x + a.y * b.y;
}
inline double operator%(const point &a, const point &b) {
  return a.x * b.y - a.y * b.x;
}
inline bool operator==(const point &a, const point &b) {
  return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0;
}
inline bool operator!=(const point &a, const point &b) { return !(a == b); }
struct line {
  point a, b, v;
  line() {}
  line(const point &a, const point &b) : a(a), b(b), v(b - a) {}
};
double sqr(double a) { return a * a; }
inline double dist(const point &a, const point &b) { return (a - b).len(); }
inline double dist(const point &a, const line &b) {
  return abs((a - b.a) % b.v) / b.v.len();
}
point operator*(const line &a, const line &b) {
  return b.a + (((a.a - b.a) % a.v) / (b.v % a.v)) * b.v;
}
bool operator*(const point &a, const line &b) {
  return ((a - b.a) * b.v) * ((a - b.b) * b.v) < -1e-8;
}
point a, b, c;
double t1, t2;
double Solve(double ratio) {
  point d = c + (b - c) * ratio;
  double lo = 0, hi = 1;
  while (lo + 1e-8 / 1000 < hi) {
    double mid = (lo + hi) / 2;
    point e = a + (d - a) * mid;
    if (dist(a, e) + dist(e, b) > t1 + 1e-8 / 100 ||
        dist(a, e) + dist(e, c) > t2 + 1e-8 / 100)
      hi = mid;
    else
      lo = mid;
  }
  point e = a + (d - a) * lo;
  return dist(a, e) +
         min(t1 - dist(a, e) - dist(e, b), t2 - dist(a, e) - dist(e, c)) +
         dist(e, b) * (c == e);
}
int main() {
  scanf("%lf%lf", &t2, &t1);
  a.read(), b.read(), c.read();
  t1 += dist(a, b), t2 += dist(a, c);
  double lo = 0, hi = 1;
  while (lo + 1e-8 / 1000 < hi) {
    double lm = lo + (hi - lo) / 3, rm = hi - (hi - lo) / 3;
    if (Solve(lm) < Solve(rm))
      lo = lm;
    else
      hi = rm;
  }
  printf("%.15f\n", max(Solve(lo), Solve(0)));
  return 0;
}