#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e8;
long long d[100][100];
int use[100][100];
bool ex[100][100];
void warshall_floid() {
  for (int k = 0; k < 100; k++) {
    for (int i = 0; i < 100; i++) {
      for (int j = 0; j < 100; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          if (use[i][j]) use[i][j]--, use[j][i]--;
          use[i][k]++;
          use[k][i]++;
          use[k][j]++;
          use[j][k]++;
        }
      }
    }
  }
}
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  fill(d[0], d[100], INF);
  for (int i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    use[a][b] = 1;
    use[b][a] = 1;
    ex[a][b] = ex[b][a] = 1;
  }
  warshall_floid();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (use[i][j] == 0 && ex[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
