#include <iostream>

#include <bits/stdc++.h>

#include <vector>

#include <queue>

#include <algorithm>

#include <limits>

#include <unordered_map>

using namespace std;

 

 

 

const long long upper_lim = 1e10;

 

 

 

vector<long long> dij(int src, int n,vector<vector<pair<long long, int>>> adj)

{

    vector<long long> dist(n + 1, upper_lim);

    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;

 

    dist[src] = 0;

    pq.push({0, src});

 

    while (!pq.empty())

    {

        auto [d, u] = pq.top();

        pq.pop();

        if (d > dist[u])

            continue;

        // cout<<dist[u];

        for (auto &[v, w] : adj[u])

        {

            if (dist[v] >= dist[u] + w)

            {

                dist[v] = dist[u] + w;

                pq.push({dist[v], v});

            }

        }

    }

 

    return dist;

}

// void func(vector<vector<int>> &adj1, vector<pair<int, int>> &dist1, vector<int> &adj2, int n, int cnt)

// {

//     for (int i = 1; i <= n; i++)

//     {

//         if (adj2[i] != numeric_limits<int>::max())

//         {

//             if (dist1[i].first <= adj2[i])

//             {

//                 cnt++;

//             }

//             else

//             {

//                 dist1[i].first = adj2[i];

 

//                 if (dist1[i].second == 1)

//                 {

//                     cnt++;

//                 }

 

//                 dist1[i].second = 1;

 

//                 add_edge(adj1, 1, i, dist1[i].first);

 

//                 dijkstra(adj1, 1, n, dist1);

//             }

//         }

//     }

//     cout << cnt << endl;

// }

 

int main()

{

    vector<vector<pair<long long, int>>> adj;

    int n, m, k;

    cin >> n >> m >> k;

 

    adj.assign(n + 1, vector<pair<long long, int>>());

 

    for (int i = 0; i < m; ++i)

    {

        int u, v;

        long long weight;

        cin >> u >> v >> weight;

        adj[u].push_back({v, weight});

        adj[v].push_back({u, weight});

    }

 

    vector<pair<int, long long>> fibers(k);

    for (int i = 0; i < k; ++i)

    {

        int u;

        long long weight;

        cin >> u >> weight;

        fibers[i] = {u, weight};

        adj[1].push_back({u, weight});

        adj[u].push_back({1, weight});

    }

 

    auto dist = dij(1, n,adj);

 

    int ans = 0;

    for (auto &[u, weight] : fibers)

    {

        for (auto it = adj[1].begin(); it != adj[1].end(); ++it)

        {

            if (it->first == u && it->second == weight)

            {

                // cout<<adj[1]<<"im erasing it"<<endl;

 

                adj[1].erase(it);

 

                break;

            }

        }

        for (auto it = adj[u].begin(); it != adj[u].end(); ++it)

        {

            if (it->first == 1 && it->second == weight)

            {

                adj[u].erase(it);

                break;

            }

        }

 

        auto next_d = dij(1, n,adj);

        if (next_d[u] == dist[u])

            ++ans;

 

        adj[1].push_back({u, weight});

        adj[u].push_back({1, weight});

    }

 

    cout << ans << endl;

 

    return 0;

}
correct code to take care of repeated cfibew onnections