#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1LL << 60;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
template <class T>
bool chmax(T &former, const T &b) {
  if (former < b) {
    former = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &former, const T &b) {
  if (b < former) {
    former = b;
    return true;
  }
  return false;
}
template <class T>
T sqar(T x) {
  return x * x;
}
template <class T>
inline void princ(T x) {
  cout << x << " ";
};
template <class T>
inline void print(T x) {
  cout << x << "\n";
};
template <class T>
inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T>
inline void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
ll n, m;
Vi a, b, c;
ll aa, bb, cc;
struct edge {
  int to, cost;
  edge(ll to_, ll cost_ = 1) {
    to = to_;
    cost = cost_;
  };
};
bool operator<(edge e1, edge e2) { return e1.cost < e2.cost; }
bool operator>(edge e1, edge e2) { return e1.cost > e2.cost; }
using graph = vector<vector<edge>>;
graph g;
matrix warshall_floyd(graph _g) {
  matrix dis(_g.size(), vector<ll>(_g.size(), INF));
  for (ll i = 0; i < (ll)dis.size(); i++) dis[i][i] = 0;
  for (ll i = 0; i < (ll)_g.size(); i++) {
    for (ll j = 0; j < (ll)_g[i].size(); j++) {
      edge e = _g[i][j];
      dis[i][e.to] = e.cost;
    }
  }
  for (ll i = 0; i < (ll)_g.size(); i++) {
    for (ll j = 0; j < (ll)_g.size(); j++) {
      for (ll k = 0; k < (ll)_g.size(); k++) {
        chmin(dis[j][k], dis[j][i] + dis[i][k]);
      }
    }
  }
  return dis;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(30);
  cin >> n >> m;
  g.resize(n);
  for (ll i = 0; i < (ll)m; i++) {
    cin >> aa >> bb >> cc;
    g[aa - 1].push_back(edge(bb - 1, cc));
    g[bb - 1].push_back(edge(aa - 1, cc));
  }
  matrix dis = warshall_floyd(g);
  matrix ck(n, Vi(n, 0));
  for (ll i = 0; i < (ll)n; i++) {
    for (ll j = 0; j < (ll)n; j++) {
      for (ll k = 0; k < (ll)n; k++) {
        if (i != k && k != j) {
          if (dis[i][j] == INF) continue;
          if (dis[i][k] == INF) continue;
          if (dis[k][j] == INF) continue;
          if (dis[i][j] == dis[i][k] + dis[k][j]) {
            ck[i][k] = 1;
            ck[k][i] = 1;
            ck[k][j] = 1;
            ck[j][k] = 1;
            dis[i][j] = 1;
            dis[j][i] = 1;
          }
        }
      }
    }
  }
  for (ll i = 0; i < (ll)n; i++) {
    for (ll j = 0; j < (ll)g[i].size(); j++) {
      edge e = g[i][j];
      if (dis[i][e.to] == e.cost) {
        ck[i][e.to] = 1;
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < (ll)n; i++) {
    for (ll j = 0; j < (ll)n; j++) {
      if (ck[i][j]) {
        if (i == j) continue;
        ans++;
      }
    }
  }
  m *= 2;
  m -= ans;
  print(m / 2);
  return 0;
}
