#include <bits/stdc++.h>
using namespace std;
long long n;
long long dis[1001];
bool vis[1001];
vector<pair<pair<long long, long long>, long long>> v[1001];
set<long long> st;
void dijkstra(long long k) {
  multiset<pair<long long, pair<long long, long long>>> s;
  s.insert({0, {0, k}});
  for (long long i = 0; i <= 1000; i++) {
    vis[i] = 0;
    dis[i] = INT_MAX;
  }
  while (!s.empty()) {
    pair<long long, pair<long long, long long>> p = *s.begin();
    s.erase(s.begin());
    long long wei = p.first;
    long long node = p.second.first;
    long long edge = p.second.second;
    if (vis[node]) continue;
    vis[node] = 1;
    st.insert(edge);
    for (long long i = 0; i < v[node].size(); i++) {
      if (!vis[v[node][i].first.first]) {
        if (wei + v[node][i].first.second < dis[v[node][i].first.first]) {
          dis[v[node][i].first.first] = wei + v[node][i].first.second;
          s.insert({dis[v[node][i].first.first],
                    {v[node][i].first.first, v[node][i].second}});
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long m;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    v[a].push_back({{b, c}, i});
    v[b].push_back({{a, c}, i});
  }
  for (long long i = 1; i <= n; i++) {
    dijkstra(i);
  }
  cout << m + 1 - st.size() << endl;
}
