#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  for (int j = 0; j < (v.size()); ++j) i >> v[j];
  return i;
}
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0; i < (v.size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream& operator<<(ostream& o, const vector<T>& v) {
  if (v.size()) o << join(v);
  return o;
}
template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {
  return o << v.first << "," << v.second;
}
const double eps = 1e-10;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else
    return 0;
}
template <class T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else
    return 0;
}
void Main() {
  int v, e;
  cin >> v >> e;
  vector<vector<int> > d(v, vector<int>(v, INF));
  vector<vector<int> > used(v, vector<int>(v, INF));
  for (int i = 0; i < (e); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    used[a][b] = 1;
    used[b][a] = 1;
  }
  int ans = 0;
  for (int k = 0; k < (v); ++k) {
    for (int i = 0; i < (v); ++i) {
      for (int j = 0; j < (v); ++j) {
        if (chmin(d[i][j], d[i][k] + d[k][j])) {
          used[i][j] = 0;
          used[i][k] = 1;
          used[k][j] = 1;
        }
      }
    }
  }
  for (int i = 0; i < (v); ++i)
    for (int j = 0; j < (v); ++j) {
      ans += used[i][j];
    }
  cout << (2 * e - ans) / 2 << endl;
}
int main(int argc, char** argv) {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ;
  ifstream iofi;
  if (argc > 1) {
    iofi.open(argv[1]);
    std::cin.rdbuf(iofi.rdbuf());
  };
  int loop = 1;
  if (argc > 2) loop = stoi(argv[2]);
  for (int i = 0; i < (loop); ++i) Main();
}
