#include <bits/stdc++.h>
using namespace std;
class Union_find {
 private:
  vector<int> par;
  vector<int> rank;
  int n;

 public:
  Union_find(int a) {
    n = a;
    for (int i = 0; i < n; i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }
  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
int main(void) {
  int n, m;
  int used[110][110] = {};
  int d[110][110];
  for (int i = 0; i < (110); i++) {
    for (int j = 0; j < (110); j++) {
      d[i][j] = 2000000000;
      d[j][i] = 2000000000;
    }
  }
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < (n); k++) {
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (n); j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          used[i][j]--;
          used[j][i]--;
          used[i][k]++;
          used[k][i]++;
          used[j][k]++;
          used[k][j]++;
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  long long res = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      if (used[i][j] == 0 && d[i][j] != 2000000000) res++;
    }
  }
  cout << res / 2 << endl;
}
