#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long a, b, c;
  vector<vector<long long> > g(n, vector<long long>(n));
  vector<vector<vector<long long> > > s(
      n, vector<vector<long long> >(n, vector<long long>()));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        g[i][j] = 0;
        s[i][j].push_back(-1);
      } else {
        g[i][j] = 1e9;
        s[i][j].push_back(-1);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = c;
    s[a][b].push_back(i);
    s[b][a].push_back(i);
  }
  set<long long> maki;
  long long niko;
  set<long long>::iterator itr;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (g[i][k] > g[i][j] + g[j][k]) {
          g[i][k] = g[i][j] + g[j][k];
          s[i][k].clear();
          niko = s[i][j].size();
          for (int x = 0; x < niko; x++) {
            maki.insert(s[i][j][x]);
          }
          niko = s[j][k].size();
          for (int x = 0; x < niko; x++) {
            maki.insert(s[j][k][x]);
          }
          for (itr = maki.begin(); itr != maki.end(); itr++) {
            s[i][k].push_back(*itr);
          }
        }
      }
    }
  }
  maki.clear();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      niko = s[i][j].size();
      for (int k = 0; k < niko; k++) {
        maki.insert(s[i][j][k]);
      }
    }
  }
  cout << m + 1 - (maki.size()) << endl;
  return 0;
}
