#include <bits/stdc++.h>
using namespace std;
int d[100][100];
pair<int, int> mp[100][100];
bool used[2000];
void calc(int a, int b, int n) {
  int now = a;
  if (now == b) return;
  for (int i = 0; i < n; i++) {
    if (mp[now][i].first + d[i][b] == d[now][b]) {
      used[mp[now][i].second] = true;
      calc(i, b, n);
      break;
    }
  }
  return;
}
int main() {
  int n, m;
  int ans = 0;
  cin >> n >> m;
  fill(d[0], d[100], 1e8 - 1);
  fill(mp[0], mp[100], pair<int, int>(1e8 - 1, 1e8 - 1));
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  fill(used, used + 2000, false);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    mp[a][b] = pair<int, int>(c, i);
    mp[b][a] = pair<int, int>(c, i);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; 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 = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      calc(i, j, n);
    }
  }
  for (int i = 0; i < m; i++) {
    if (!used[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
