#include <bits/stdc++.h>
using namespace std;
int n, m;
long long d[105][105], D[105][105];
void warshall_floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      d[i][j] = 1e9;
      D[i][j] = 1e9;
    }
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    D[a][b] = c;
    D[b][a] = c;
  }
  warshall_floyd();
  set<pair<int, int>> c;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        if (D[i][j] + d[j][k] == d[i][k]) {
          int a = min(i, j), b = max(i, j);
          c.insert(make_pair(a, b));
          break;
        }
      }
    }
  }
  cout << m - c.size() << endl;
}
