#include <bits/stdc++.h>
using namespace std;
long long c[102][102], s[102], e[102], co[102];
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < 102; i++) {
    for (int j = 0; j < 102; j++) {
      c[i][j] = c[j][i] = 1000000007;
    }
  }
  for (int i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    s[i] = x;
    e[i] = y;
    co[i] = z;
    c[x][y] = c[y][x] = z;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    long long nows = s[i];
    long long nowe = e[i];
    long long nowcos = co[i];
    if (c[nows][nowe] != nowcos) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
