
// Problem: C - Unexpressed
// Contest: AtCoder - Caddi Programming Contest 2021(AtCoder Beginner Contest 193)
// URL: https://atcoder.jp/contests/abc193/tasks/abc193_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" 
//#pragma GCC diagnostic ignored "-Wformat"

using namespace std ;

#define   Pi     2*acos(0.0)
#define   LINF   1LL<<62
#define   ll     long long
#define   ull    unsigned long long
#define   pb     push_back
#define   mp     make_pair
#define   MAX    500006
#define   MAX1   10000008
#define   mem(a,v)   memset(a,v,sizeof(a))
#define   all(x) x.begin(),x.end()
#define   lcm(a, b)        ((a)*((b)/__gcd(a,b)))
#define yes   cout<<"YES"<<endl
#define no   cout<<"NO"<<endl
#define buga  cout<<1<<endl
#define bugb  cout<<2<<endl
#define bugc  cout<<3<<endl
#define bugd  cout<<4<<endl
#define buge  cout<<5<<endl

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}
/*
ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}
 
/*
/*
ll bin_pow(ll o, ll s) {
    if (s == 0) return 1;
    if (s == 1) return o % mod;
    ll d = bin_pow(o, s/2);
    d = (d * 1ll * d) % mod;
    if (s % 2 == 1)
        d = (d * 1ll * o) % mod;
    return d;
}
*/

int main ()
{
    fastIO();
    ll a,b,c,d,n,m,k,l,p,q,r,t,x,y;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    ll Max= 0,Max1=-1e18+1,Min=LINF;
    string s,s1,s3,s4;

    //cin>>n;
    for(ll i = 2; i <= 100000; i++){
        ans = i;
        for(int j = 1; ans <= 10000000000LL; j++){
            ans = 1LL * ans * i;
            V.push_back(ans);
        }
    }
    sort(V.begin(), V.end());
    V.resize(unique(V.begin(), V.end())- V.begin());
    V.push_back(10000000000000LL);
    //cout << V.size() << endl;
    cin >> n;
    int idx = upper_bound(V.begin(), V.end(), n) - V.begin();
    if(n <= 3) cout <<  n << endl;
    else cout << n - idx << endl;
    /* 
        always check the limit and make sure that is correct.
        lcm of first 40 numbers  can be calculated.
        sqrt of 10^9 is 31622.
        always usee 1LL while doing binary operations.
    */

    return 0;
}

// Bismillahir Rahmanir Rahim
//============================
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define endl        "\n"
#define infL        LLONG_MAX
#define infI        INT_MAX
#define pb          push_back
#define fo(i,a,b)   for(int i=a;i<b;i++)
#define fo2(i,a,b)  for(int i=a;i<=b;i++)
#define rfo(i,a,b)  for(int i=a; i>=b;i--)
#define precise(x,y)cout<<fixed<<setprecision(y)<<x<<endl;
#define MAX         100010
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0
#define debug       cout<<"\nDebug\n";
#define debug2      cout<<"\nDebug2\n";
#define PEREGRINE_FALCON {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

typedef pair<ll,ll>PII;
double epsilon = 0.0000001f;
ll mod=1e9+7;
double Pi =acos(-1);

void print(vector<ll>V)
{
      cout<<"\n---------------Vector checking start-------------------\n";
      ll sz=V.size();
      fo(i,0,sz){cout<<V[i]<<"  ";}
      cout<<"\n----------------Vector checking end--------------------\n";
}

void print(ll arr[], ll n)
{
      cout<<"\n---------------Array checking start-------------------\n";
      fo(i,0,n){cout<<arr[i]<<" ";}
      cout<<"\n----------------Array checking end--------------------\n";
}

int main()
{
      PEREGRINE_FALCON
      //freopen("inputNew.txt", "r", stdin);

      ll testCase=1;
      //cin>>testCase;
      while(testCase--){
            ll n,m,k,x,y,z,d,mn,mx,temp,cnt,ans,sum,sz,len;
            cin>>n;
            ll a[n+10],b[n+10],c[n+10];
            ll markA[n+10]={0};
            ll markC[n+10]={0};

            fo(i,0,n){
                  cin>>a[i];
                  markA[a[i]]++;
            }
            fo(i,0,n){
                  cin>>b[i];
            }
            fo(i,0,n){
                  cin>>c[i];
                  markC[c[i]]++;
            }

            cnt=0;
            fo2(i,1,n){
                  if(markC[i]==0) continue;
                  x=markC[i];
                  y=b[i-1];
                  //cout<<"x: "<<x<<endl;
                  if(markA[y]){
                        cnt+=(markA[y]*x);
                  }
            }
            cout<<cnt<<endl;

      }

      bye;
}
