#include <bits/stdc++.h>
const int N = (100000) + 322;
const int INF = (long long)(2e9) + 7;
using namespace std;
int pr[N], a[N], n, pos[N], m, d[111][111], cost[111][111];
struct edge {
  int x, y, cost;
};
vector<edge> e;
bool get(int x, int y, int cost) {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (d[i][j] == d[i][x] + d[y][j] + cost ||
          d[i][j] == d[i][y] + d[j][x] + cost)
        return 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    e.push_back({x, y, c});
    d[x][y] = c;
    d[y][x] = c;
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int cnt = 0;
  for (auto it : e) {
    cnt += get(it.x, it.y, it.cost);
  }
  cout << m - cnt;
  return 0;
}
