#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T>> P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (auto it : P) {
    s << "<" << it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (auto it : P) {
    s << "<" << it.first << "->" << it.second << "> ";
  }
  return s << endl;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;
long int M = 1e+9 + 7;
int inf = 1e+9;
int n, m;
int solve() {
  int ans = 0;
  vvi d(n + 1, vi(n + 1, inf));
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int i = 1; i <= (n); ++i) {
    d[i][i] = 0;
  }
  vector<vector<bool>> br(n + 1, vector<bool>(n + 1, true));
  for (int k = 1; k <= (n); ++k) {
    for (int i = 1; i <= (n); ++i) {
      for (int j = 1; j <= (n); ++j) {
        if (chmin(d[i][j], d[i][k] + d[k][j])) {
          br[i][j] = false;
        }
      }
    }
  }
  for (int i = 1; i <= (n - 1); ++i) {
    if (!br[i][i + 1]) ans++;
  }
  return ans;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  while (cin >> n >> m) {
    int ans = 0;
    cout << solve() << endl;
  }
  return 0;
}
