#include <bits/stdc++.h>
using namespace std;

struct Edge {
  int to, w;
};

typedef vector<vector<Edge> > Graph;


int dfsB(const Graph &g, int v, int prev, int &times, vector<int> &num,
         vector<Edge> &bridge) {
  int res = num[v] = times++;
  for(int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i].to;
    int t;
    if(num[nv] == -1) {
      t = dfsB(g, nv, v, times, num, bridge);
      if(t > num[v]) {
        bridge.push_back(g[v][i]);
      }
    } else {
      t = num[nv];
    }
    if(nv != prev) {
      res = min(res, t);
    }
  }
  return res;
}

vector<Edge> getBridge(const Graph &g) {
  vector<Edge> res;
  int n = g.size();
  int times = 0;
  vector<int> num(n, -1);
  for(int i = 0; i < n; ++i) {
    if(num[i] == -1) {
      dfsB(g, i, -1, times, num, res);
    }
  }
  return res;
}

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<pair<int, pair<int, int> > > es;
    for (int i = 0; i < M; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a; --b;
      es.push_back(make_pair(c, make_pair(a, b)));
    }
    sort(es.begin(), es.end());
    Graph G(N);
    int A = 0, B = 0;
    for (int i = 0; i < es.size(); ) {
      int W = es[i].first;
      while (i < es.size() && es[i].first == W) {
        G[es[i].second.first].push_back((Edge){es[i].second.second, W});
        G[es[i].second.second].push_back((Edge){es[i].second.first, W});
        ++i;
      }
      vector<Edge> b = getBridge(G);
      for (int k = 0; k < b.size(); ++k) {
        if (b[k].w == W) {
          ++A;
          B += b[k].w;
        }
      }
    }
    cout << A << " " << B << endl;
  }
  return 0;
}