#include using namespace std; using ll = long long int; using ull = unsigned long long int; using P = pair; using P3 = pair; using PP = pair; constexpr int INF32 = 1 << 30; constexpr ll INF64 = 1LL << 62; // constexpr ll MOD = 1000000007; constexpr ll MOD = 998244353; constexpr int di[] = {0, 1, 0, -1}; constexpr int dj[] = {1, 0, -1, 0}; constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1}; constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1}; constexpr double EPS = 1e-10; const double PI = acos(-1); #define ALL(v) (v).begin(),(v).end() #define REP(i,n) for(int i=0,i_len=n; i bool chmax(T1 &a, T2 b) { if (a bool chmin(T1 &a, T2 b) { if (b> n; vector a(n), pos(n); vector used(n); REP(i,n){ cin >> a[i]; a[i]--; pos[a[i]] = i; } int ans = 0; REP(i,n){ if(!used[i]){ ans++; used[i] = true; if(pos[i]>0) used[a[pos[i]-1]] = true; } } cout << ans << endl; return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(0); cout<> t; for(int i=0;i