#include <bits/stdc++.h>
using namespace std;
long long ch[102][102], a[21002], b[21002], c[201002];
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < 102; i++) {
    for (long long j = 0; j < 102; j++) {
      ch[i][j] = 1LL << 62;
      if (i == j) {
        ch[i][j] = 0;
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    ch[x][y] = ch[y][x] = z;
    a[i] = x;
    b[i] = y;
    c[i] = z;
  }
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        ch[i][j] = min(ch[i][j], ch[i][k] + ch[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    if (ch[a[i]][b[i]] == c[i]) {
      ans++;
    }
  }
  cout << m - ans;
  return 0;
}
