#include <bits/stdc++.h>
using namespace std;
int N, M, a[210001], b[210001], c[210001];
int d[101][101], e[101][101];
int f[210001];
int ans;
int main(void) {
  cin >> N >> M;
  for (int i = 1; i <= M; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      d[i][j] = 100000000;
      e[i][j] = 100000000;
    }
  for (int i = 1; i <= N; i++) d[i][i] = 0;
  for (int i = 1; i <= M; i++) {
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
    e[a[i]][b[i]] = i;
    e[b[i]][a[i]] = i;
  }
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= N; j++)
        if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
  for (int i = 1; i <= N; i++)
    for (int i = 1; i <= N; i++) f[i] = 0;
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= N; j++) {
        if (i == j || i == k || j == k) continue;
        if (d[i][j] == d[i][k] + d[k][j]) {
          f[k] = 1;
        }
      }
  for (int i = 1; i <= M; i++) f[i] = 1;
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= N; j++) {
        if (i == j || k == i || k == j) continue;
        if (d[i][k] == c[e[i][k]]) f[e[i][k]] = 0;
        if (d[k][j] == c[e[k][j]]) f[e[k][j]] = 0;
      }
  ans = 0;
  for (int i = 1; i <= M; i++)
    if (f[i] == 1) ans++;
  cout << ans << endl;
  return 0;
}
