#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const int INF = 1e7;
int n, m, d[MAX][MAX];
vector<pair<int, pair<int, int> > > v;
void warshall_floyd() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}
int check() {
  int res = 0;
  bool check;
  for (int i = 0; i < m; i++) {
    check = true;
    for (int j = 0; j < n; j++) {
      if (!check) break;
      if (d[j][v[i].second.first] + v[i].first == d[j][v[i].second.second]) {
        res += 1;
        check = false;
      }
    }
  }
  return res;
}
int main() {
  int a, b, c, ans;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) d[i][j] = INF;
    d[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    v.push_back(make_pair(c, pair<int, int>(a - 1, b - 1)));
  }
  warshall_floyd();
  ans = check();
  cout << m - ans << endl;
  return 0;
}
