#include <bits/stdc++.h>
using namespace std;
unsigned long long int intmxi = 10000000001;
unsigned long long int ans = 0;
void djik(
    vector<vector<pair<unsigned long long int,
                       pair<unsigned long long int, unsigned long long int>>>>
        g,
    vector<unsigned long long int>& sp) {
  set<unsigned long long int> s;
  unsigned long long int n = g.size();
  priority_queue<
      pair<unsigned long long int,
           pair<unsigned long long int, unsigned long long int>>,
      vector<pair<unsigned long long int,
                  pair<unsigned long long int, unsigned long long int>>>,
      greater<pair<unsigned long long int,
                   pair<unsigned long long int, unsigned long long int>>>>
      pq;
  pq.push(make_pair(0, make_pair(0, 0)));
  while (s.size() < g.size()) {
    unsigned long long int u, du;
    while (!pq.empty()) {
      unsigned long long int ch = pq.top().second.first;
      u = pq.top().second.second;
      du = pq.top().first;
      pq.pop();
      if (s.count(u) == 0) {
        if (ch == 1) {
          ans--;
        }
        break;
      }
    }
    s.insert(u);
    sp[u] = du;
    for (unsigned long long int i = 0; i < g[u].size(); i++) {
      if (s.count(g[u][i].first) > 0) continue;
      pq.push(make_pair(sp[u] + g[u][i].second.first,
                        make_pair(g[u][i].second.second, g[u][i].first)));
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  unsigned long long int t = 1;
  while (t--) {
    unsigned long long int n, m, k;
    cin >> n >> m >> k;
    vector<vector<pair<unsigned long long int,
                       pair<unsigned long long int, unsigned long long int>>>>
        g(n);
    vector<unsigned long long int> tr(n, -1);
    for (unsigned long long int i = 0; i < m; i++) {
      unsigned long long int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      g[a].push_back(make_pair(b, make_pair(c, 0)));
      g[b].push_back(make_pair(a, make_pair(c, 0)));
    }
    ans = k;
    for (unsigned long long int i = 0; i < k; i++) {
      unsigned long long int a, b;
      cin >> a >> b;
      a--;
      if (tr[a] != -1) {
        tr[a] = min(tr[a], b);
      } else {
        tr[a] = b;
      }
    }
    for (unsigned long long int i = 0; i < n; i++) {
      if (tr[i] != -1) {
        g[0].push_back(make_pair(i, make_pair(tr[i], 1)));
      }
    }
    vector<unsigned long long int> sp(n, intmxi);
    sp[0] = 0;
    djik(g, sp);
    cout << ans << endl;
  }
}
