#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
static const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v;
  v = vector<vector<int> >(n + 1, vector<int>(n + 1, INF));
  vector<vector<bool> > used;
  for (int i = 0; i < (int)n + 1; ++i) v[i][i] = 0;
  used = vector<vector<bool> >(n + 1, vector<bool>(n + 1, false));
  for (int i = 0; i < (int)m + 1; ++i) used[0][i] = true, used[i][0] = true;
  vector<int> a, b, c;
  a.push_back(0), b.push_back(0), c.push_back(0);
  for (int i = 0; i < (int)m; ++i) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    v[ai][bi] = ci;
    v[bi][ai] = ci;
    a.push_back(ai);
    b.push_back(bi);
    c.push_back(ci);
  }
  vector<vector<int> > edges;
  edges = v;
  for (int k = 0; k < n + 1; k++) {
    for (int i = 0; i < n + 1; i++) {
      for (int j = 0; j < n + 1; j++) v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
    }
  }
  int cnt = m;
  for (int i = 1; i < m + 1; i++) {
    bool flag = false;
    for (int j = 1; j < n + 1; j++) {
      for (int k = 1; k < n + 1; k++) {
        long long temp = v[j][a[i]] + c[i] + v[b[i]][k];
        if (temp == v[j][k]) flag = true;
      }
    }
    if (flag) cnt--;
  }
  cout << cnt << endl;
}
