#include <bits/stdc++.h>
using namespace std;
int dy[4] = {-1, 1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int d[110][110];
map<int, map<int, int> > ext;
int N, M;
int main() {
  ios::sync_with_stdio(false);
  for (long long i = 0; i < (long long)(110); i++)
    for (long long j = 0; j < (long long)(110); j++) {
      d[i][j] = 1000000007LL;
    }
  cin >> N >> M;
  for (long long i = 0; i < (long long)(N); i++) {
    d[i][i] = 0;
  }
  for (long long i = 0; i < (long long)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    ext[a][b] = 1;
    ext[b][a] = 1;
    d[a][b] = c;
    d[b][a] = c;
  }
  int ans = 0;
  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]) {
          d[i][j] = d[i][k] + d[k][j];
          if (ext[i][k] == 1 && ext[k][i] == 1) {
            ans++;
            ext[i][k]++;
            ext[k][i]++;
          }
          if (ext[j][k] == 1 && ext[k][j] == 1) {
            ans++;
            ext[j][k]++;
            ext[k][j]++;
          }
        }
      }
    }
  }
  cout << M - ans << endl;
  return 0;
}
