#include <bits/stdc++.h>
using namespace std;
const int MX1 = 1e2 + 5;
const int MX2 = 1e6 + 5;
const long long int inf = 1e18;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b % 2) res = (res * a) % (long long int)(1e9 + 7);
    a = (a * a) % (long long int)(1e9 + 7);
    b /= 2;
  }
  return res;
}
long long int mmi(long long int a) {
  return power(a, (long long int)(1e9 + 7) - 2);
}
long long int cntbit(long long int n) {
  long long int cnt = 0;
  while (n) {
    n &= (n - 1);
    cnt++;
  }
  return cnt;
}
int n, m, x[MX1], y[MX1], c[MX1];
long long int dis[MX1][MX1], mark[MX1];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dis[i][j] = (long long int)(1e9 + 7);
    }
    dis[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x[i] >> y[i] >> c[i];
    dis[x[i]][y[i]] = c[i];
    dis[y[i]][x[i]] = c[i];
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= m; k++) {
        if (dis[i][x[k]] + c[k] + dis[y[k]][j] == dis[i][j]) {
          mark[k] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (mark[i] == 0) ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
