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;
double eps = 1e-10;
struct dot {
  double x, y;
  dot(double xx = 0, double yy = 0) { x = xx, y = yy; }
};
dot shop, cinema, house;
double t1, t2;
dot operator-(dot a, dot b) { return (dot(a.x - b.x, a.y - b.y)); }
double dist(dot a) {
  return sqrt((double)a.x * (double)a.x + (double)a.y * (double)a.y + eps);
}
double ans = 0;
int in_or_on_circle(dot a, double ra, dot b) {
  if (dist(b - a) <= ra + eps) return 1;
  return 0;
}
int flag;
pair<dot, dot> line_with_circle(double kk, double bb, dot b, double rb) {
  flag = 0;
  ;
  double x1 = b.x, y1 = b.y;
  double A = (1 + kk * kk), B = -2 * x1 + 2 * kk * bb - 2 * y1 * kk,
         C = x1 * x1 + bb * bb - 2 * y1 * bb + y1 * y1 - rb * rb;
  double delta = (B * B - 4 * A * C) + eps;
  if (delta < 0) return make_pair((dot)(0, 0), (dot)(0, 0));
  flag = 1;
  dot gg1, gg2;
  double gx = (-B + sqrt(delta)) / 2 / A;
  gg1 = dot(gx, gx * kk + bb);
  gx = (-B - sqrt(delta)) / 2 / A;
  gg2 = dot(gx, gx * kk + bb);
  return make_pair(gg1, gg2);
}
pair<dot, dot> circle_with_circle(dot a, double ra, dot b, double rb) {
  flag = 0;
  double cd, cf;
  int swa = 0;
  if (fabs(a.y - b.y) <= eps) swap(a.x, a.y), swap(b.x, b.y), swa = 1;
  ;
  cd = (2 * b.x - 2 * a.x) / (2 * a.y - 2 * b.y),
  cf = (a.x * a.x - b.x * b.x + a.y * a.y - b.y * b.y - ra * ra + rb * rb) /
       (2 * a.y - 2 * b.y);
  pair<dot, dot> po = line_with_circle(cd, cf, b, rb);
  if (swa) swap(po.first.x, po.first.y), swap(po.second.x, po.second.y);
  return po;
}
int overlap(dot a, double ra, dot b, double rb, dot c, double rc) {
  pair<dot, dot> u;
  u = circle_with_circle(a, ra, b, rb);
  if (flag and in_or_on_circle(c, rc, u.first)) return 1;
  if (flag and in_or_on_circle(c, rc, u.second)) return 1;
  u = circle_with_circle(a, ra, c, rc);
  if (flag and in_or_on_circle(b, rb, u.first)) return 1;
  if (flag and in_or_on_circle(b, rb, u.second)) return 1;
  u = circle_with_circle(b, rb, c, rc);
  if (flag and in_or_on_circle(a, ra, u.first)) return 1;
  if (flag and in_or_on_circle(a, ra, u.second)) return 1;
  if (in_or_on_circle(a, ra, b) and in_or_on_circle(c, rc, b)) return 1;
  if (in_or_on_circle(a, ra, c) and in_or_on_circle(b, rb, c)) return 1;
  if (in_or_on_circle(b, rb, a) and in_or_on_circle(c, rc, a)) return 1;
  return 0;
}
double calc(double mid) {
  double d1 = t1 - mid, d2 = t2 - mid;
  if (d1 < 0 or d2 < 0) return 0;
  if (overlap(cinema, mid, shop, d1, house, d2)) return 1;
  return 0;
}
int main() {
  cin >> t1 >> t2 >> cinema.x >> cinema.y >> house.x >> house.y >> shop.x >>
      shop.y;
  t1 = t1 + dist(cinema - shop);
  t2 = t2 + dist(cinema - house);
  if (t2 >= dist(cinema - shop) + dist(shop - house) - eps) {
    printf("%.8lf", min(t1 + dist(shop - house), t2));
    return 0;
  }
  double l = 0, r = 1002;
  double ans = 0;
  while (r - l > 1e-10) {
    double mid = (l + r) / 2;
    if (calc(mid)) {
      l = mid + 1e-10;
      ans = mid;
    } else {
      r = mid - 1e-10;
    }
  }
  printf("%.8lf", ans);
}