#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<long long int>> G(N, vector<long long int>(N, 0));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = c;
    G[b][a] = c;
  }
  vector<vector<bool>> ch(N, vector<bool>(N, false));
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int tmp = G[i][j];
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
        if (tmp != G[i][j]) ch[i][j] = true;
      }
    }
  }
  int ct = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (ch[i][j]) ct++;
  if (ct < N - 1) ct = N - 1;
  cout << M - ct << endl;
}
