#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 55;
const double pi = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const vector<int> emp;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, -0};
const int DX[8] = {-1, -1, -1, 0, 0, 1, 1, 1},
          DY[8] = {1, 0, -1, 1, -1, 1, 0, -1};
map<pair<int, int>, int> m;
class Graph {
 private:
  int V, E;
  vector<vector<pair<int, int> > > List;
  vector<int> DIJ(int s) {
    priority_queue<pair<int, int> > que;
    vector<int> d(V, inf);
    d[s] = 0;
    que.push(pair<int, int>(0, s));
    while (!que.empty()) {
      pair<int, int> p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < -p.first) continue;
      for (int i = 0; i < List[v].size(); i++) {
        int F = List[v][i].first, S = List[v][i].second;
        if (d[F] > d[v] + S) {
          d[F] = d[v] + S;
          que.push(pair<int, int>(-d[F], F));
        }
      }
    }
    return d;
  }

 public:
  Graph(int v, int e) {
    V = v;
    E = e;
    List = vector<vector<pair<int, int> > >(v);
  }
  void add_edge(int s, int t, int c) {
    List[s].push_back(pair<int, int>(t, c));
    List[t].push_back(pair<int, int>(s, c));
  }
  int solve() {
    vector<bool> a(E, 0);
    for (int i = 0; i < V; i++) {
      vector<int> d = DIJ(i);
      for (int j = 0; j < V; j++)
        for (int k = 0; k < List[j].size(); k++) {
          pair<int, int> v = List[j][k];
          if (d[j] == d[v.first] + v.second)
            a[m[pair<int, int>(j, v.first)]] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < E; i++)
      if (!a[i]) ans++;
    return ans;
  }
};
int n, e;
int main() {
  cin >> n >> e;
  Graph g(n, e);
  for (int i = 0; i < e; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    s--;
    t--;
    g.add_edge(s, t, c);
    m[pair<int, int>(s, t)] = i;
  }
  cout << g.solve() << endl;
}
