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 readPoint() {
  double x, y;
  cin >> x >> y;
  Point p = {x, y};
  return p;
}
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> ccCross(Point &p1, double r1, Point &p2, double r2) {
  double d = dist(p1, p2);
  double t = ((d * d + r1 * r1 - r2 * r2) / (2.0 * d)) / d;
  double fx = p1.x + t * (p2.x - p1.x), fy = p1.y + t * (p2.y - p1.y);
  double h = sqrt(max(r1 * r1 - t * d * t * d, 0.0));
  double dx = (p2.y - p1.y) * (h / d), dy = (p1.x - p2.x) * (h / d);
  vector<Point> ret;
  Point t1 = {fx + dx, fy + dy};
  Point t2 = {fx - dx, fy - dy};
  ret.push_back(t1);
  ret.push_back(t2);
  return ret;
}
bool tri(double a, double b, double c) {
  double d[] = {a, b, c};
  sort(d, d + 3);
  return (d[0] + d[1] + 1e-12 > d[2]);
}
bool possible(Point &p1, double r1, Point &p2, double r2, Point &p3,
              double r3) {
  if (dist(p1, p2) < r2 + 1e-12 && dist(p1, p3) < r3 + 1e-12) return true;
  if (dist(p2, p1) < r1 + 1e-12 && dist(p2, p3) < r3 + 1e-12) return true;
  if (dist(p3, p1) < r1 + 1e-12 && dist(p3, p2) < r2 + 1e-12) return true;
  if (tri(dist(p1, p2), r1, r2)) {
    vector<Point> ip = ccCross(p1, r1, p2, r2);
    if (dist(ip[0], p3) < r3 + 1e-12) return true;
    if (dist(ip[1], p3) < r3 + 1e-12) return true;
  }
  if (tri(dist(p1, p3), r1, r3)) {
    vector<Point> ip = ccCross(p1, r1, p3, r3);
    if (dist(ip[0], p2) < r2 + 1e-12) return true;
    if (dist(ip[1], p2) < r2 + 1e-12) return true;
  }
  if (tri(dist(p2, p3), r2, r3)) {
    vector<Point> ip = ccCross(p2, r2, p3, r3);
    if (dist(ip[0], p1) < r1 + 1e-12) return true;
    if (dist(ip[1], p1) < r1 + 1e-12) return true;
  }
  return false;
}
int main() {
  double t1, t2;
  cin >> t1 >> t2;
  Point A = readPoint(), B = readPoint(), C = readPoint();
  if (dist(A, C) + dist(C, B) < dist(A, B) + t2 + 1e-12) {
    cout << fixed << setprecision(9)
         << min(dist(A, C) + dist(C, B) + t1, dist(A, B) + t2) << endl;
    return 0;
  }
  double low = 0, mid = 0, high = min(dist(A, C) + t1, dist(A, B) + t2);
  for (int i = 0; i < 100; ++i) {
    mid = (low + high) / 2.0;
    if (possible(A, mid, B, dist(A, B) + t2 - mid, C, dist(A, C) + t1 - mid))
      low = mid;
    else
      high = mid;
  }
  cout << fixed << setprecision(9) << mid << endl;
  return 0;
}