#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = acos((long double)0) * 2;
const int MAXN = 1100;
struct pt {
  long double x, y;
  pt() {}
  pt(long double x, long double y) : x(x), y(y) {}
  pt operator-(const pt& p) const { return pt(x - p.x, y - p.y); }
};
struct line {
  long double a, b, c;
  void norm() {
    long double z = sqrt(a * a + b * b);
    a /= z, b /= z, c /= z;
    if (c > EPS) {
      a = -a;
      b = -b;
      c = -c;
    }
  }
};
int n, k;
pt p[MAXN];
long double r[MAXN];
bool read() {
  if (!(cin >> n >> k)) return false;
  for (int i = 0; i < int(n); ++i) {
    int x, y, rr;
    scanf("%d%d%d", &x, &y, &rr);
    p[i].x = x;
    p[i].y = y;
    r[i] = rr;
  }
  return true;
}
inline long double sqr(long double a) { return a * a; }
inline long double norm(long double a) {
  while (a < -PI) a += 2 * PI;
  while (a > PI) a -= 2 * PI;
  return a;
}
inline void tangents(pt c, long double r1, long double r2, vector<line>& ans) {
  long double r = r2 - r1;
  long double z = sqr(c.x) + sqr(c.y);
  long double d = z - sqr(r);
  if (d < -EPS) return;
  d = sqrt(abs(d));
  line l;
  l.a = (c.x * r + c.y * d) / z;
  l.b = (c.y * r - c.x * d) / z;
  l.c = r1;
  l.norm();
  ans.push_back(l);
}
vector<line> tangents(pt a, long double ar, pt b, long double br) {
  vector<line> ans;
  for (int i = -1; i <= 1; i += 2)
    for (int j = -1; j <= 1; j += 2) tangents(b - a, ar * i, br * j, ans);
  return ans;
}
struct event {
  long double ang;
  int bal;
  event() {}
  event(long double ang, int bal) : ang(ang), bal(bal) {}
  bool operator<(const event& e) const {
    if (abs(ang - e.ang) > EPS) return ang < e.ang;
    return bal < e.bal;
  }
};
vector<event> e;
inline void add_events(int i, line l1, line l2) {
  long double ang1 = atan2(l1.b, l1.a), ang2 = atan2(l2.b, l2.a);
  if (ang2 < ang1)
    if (ang1 - ang2 > PI)
      ang2 += 2 * PI;
    else
      swap(ang1, ang2);
  if (ang2 <= ang1 + EPS) throw;
  for (int i = -2; i <= 2; ++i) {
    long double l = ang1 + 2 * PI * i, r = ang2 + 2 * PI * i;
    e.push_back(event(l, +1));
    e.push_back(event(r, -1));
  }
}
int solve_events() {
  sort(e.begin(), e.end());
  int ans = 0, bal = 0;
  for (int i = 0; i < int(e.size()); ++i) {
    long double ang = e[i].ang;
    while (i < (int)e.size() && abs(ang - e[i].ang) < EPS) {
      bal += e[i++].bal;
      if (bal < 0 || bal >= n) throw;
    }
    --i;
    ans = max(ans, bal);
  }
  return ans + 1;
}
long long formula(long long k, long long cnt) {
  if (!cnt) return 0;
  return (1 + k * (k + 1) / 2) + (cnt - 1) * (k + 1) + (n - cnt);
}
void solve() {
  long long ans = 0;
  for (int i = 0; i < int(n); ++i) {
    e.clear();
    for (int j = 0; j < int(n); ++j)
      if (i != j) {
        vector<line> l = tangents(p[i], r[i], p[j], r[j]);
        add_events(i, l[0], l[1]);
        add_events(i, l[2], l[3]);
      }
    int cnt = solve_events();
    ans = max(ans, formula(k, cnt));
  }
  cout << ans << endl;
}
int main() {
  if (!read()) throw;
  solve();
}
