#include <iostream>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
int main()
    {
        ios_base::sync_with_stdio(false);
        int n;
        int answer = 0;
        cin >> n;
        for(int i = 0; i < n; i++) {
            string a, b;
            cin >> a >> b;
            sort(a.begin(), a.end());
            sort(b.begin(), b.end());
            if(a == b) {
                answer++;
            }
        }
        cout << answer << endl;
        return 0;
    }
// ({})
