#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int n;
  char x[10000], y[10000];
  int dp[10010][10010];
  // load n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    // load string
    scanf("%s", x);
    scanf("%s", y);
    // dp
    for (int j = 0; j < strlen(x); j++) {
      for (int k = 0; k < strlen(y); k++) {
        if (x[j] == y[k]) {
          dp[j + 1][k + 1] = dp[j][k] + 1;
        }

        else {
          if (dp[j][k + 1] > dp[j + 1][k]) {
            dp[j + 1][k + 1] = dp[j][k + 1];
          }

          else {
            dp[j + 1][k + 1] = dp[j + 1][k];
          }
        }
      }
    }
    cout << dp[strlen(x)][strlen(y)] << endl;
  }

  return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int n;
  char x[1001], y[1001];
  int dp[1010][1010];
  // load n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    // load string
    scanf("%s", x);
    scanf("%s", y);
    // dp
    for (int j = 0; j < strlen(x); j++) {
      for (int k = 0; k < strlen(y); k++) {
        if (x[j] == y[k]) {
          dp[j + 1][k + 1] = dp[j][k] + 1;
        }

        else {
          if (dp[j][k + 1] > dp[j + 1][k]) {
            dp[j + 1][k + 1] = dp[j][k + 1];
          }

          else {
            dp[j + 1][k + 1] = dp[j + 1][k];
          }
        }
      }
    }
    cout << dp[strlen(x)][strlen(y)] << endl;
  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
#define MAX 100000

static const int N = 100;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int ans = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i; i <= m; i++)
    c[i][0] = 0;
  for (int j; j <= n; j++)
    c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      ans = max(ans, c[i][j]);
    }
  }
  return ans;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
#define MAX 100000

static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int ans = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i; i <= m; i++)
    c[i][0] = 0;
  for (int j; j <= n; j++)
    c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      ans = max(ans, c[i][j]);
    }
  }
  return ans;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

void fnInput(vector<string> &rvsStrX, vector<string> &rvsStrY) {
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i) {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string> &cnrvsStrX,
                   const vector<string> &cnrvsStrY) {
  vector<vector<int>> vvnLcsDP;
  for (int i = 0; i < cnrvsStrX.size(); ++i) {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();

    //    vvnLcsDP.clear();
    vvnLcsDP.resize(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

void fnInput(vector<string> &rvsStrX, vector<string> &rvsStrY) {
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i) {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string> &cnrvsStrX,
                   const vector<string> &cnrvsStrY) {
  vector<vector<int>> vvnLcsDP;
  for (int i = 0; i < cnrvsStrX.size(); ++i) {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();

    vvnLcsDP.clear();
    vvnLcsDP.resize(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i, a, n) for (int i = (a), i##_len = (n); i < i##_len; ++i)
#define rrep(i, a, n) for (int i = (a), i##_len = (n); i > i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e4;
inline int lcs(string X, string Y) {
  vv(int, c, MAX + 1, MAX + 1, 0);
  int m = len(X);
  int n = len(Y);
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  rep(i, 1, m + 1) {
    rep(j, 1, n + 1) {
      if (X[i] == Y[j])
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      if (maxl < c[i][j])
        maxl = c[i][j];
    }
  }
  return maxl;
}
int main() {
  int n;
  cin >> n;
  string s1, s2;
  rep(i, 0, n) {
    cin >> s1 >> s2;
    P(lcs(s1, s2));
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i, a, n) for (int i = (a), i##_len = (n); i < i##_len; ++i)
#define rrep(i, a, n) for (int i = (a), i##_len = (n); i > i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1005;
inline int lcs(string X, string Y) {
  vv(int, c, MAX, MAX, 0);
  int m = len(X);
  int n = len(Y);
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  rep(i, 1, m + 1) {
    rep(j, 1, n + 1) {
      if (X[i] == Y[j])
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      if (maxl < c[i][j])
        maxl = c[i][j];
    }
  }
  return maxl;
}
int main() {
  int n;
  cin >> n;
  string s1, s2;
  rep(i, 0, n) {
    cin >> s1 >> s2;
    P(lcs(s1, s2));
  }
  return 0;
}


// ALDS1_10_C.cpp
// Dynamic Programming - Longest Common Subsequence

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int LCS(string s, string t) {
  int res = 0;
  if (s.empty() || t.empty())
    return res;
  string s1(s.begin() + 1, s.end());
  string t1(t.begin() + 1, t.end());
  if (s[0] == t[0]) {
    res = 1 + LCS(s1, t1);
  } else {
    res = max(LCS(s1, t), LCS(s, t1));
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  string s, t;
  while (n--) {
    cin >> s >> t;
    int res = LCS(s, t);
    cout << res << endl;
  }
  return 0;
}

// ALDS1_10_C.cpp
// Dynamic Programming - Longest Common Subsequence

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int LCS(string s, string t) {
  int res = 0;
  if (s.empty() || t.empty())
    return res;
  int s_len = s.size();
  int t_len = t.size();
  int len = min(s_len, t_len);
  //    int lcs[s_len][t_len];
  vector<vector<int>> lcs(s_len, vector<int>(t_len));
  bool found = false;
  for (int i = 0; i < s_len; i++) {
    if (s[i] == t[0] || found) {
      lcs[i][0] = 1;
      found = true;
    }
  }
  found = false;
  for (int j = 0; j < t_len; j++) {
    if (s[0] == t[j] || found) {
      lcs[0][j] = 1;
      found = true;
    }
  }
  for (int i = 1; i < s_len; i++) {
    for (int j = 1; j < t_len; j++) {
      if (s[i] == t[j]) {
        lcs[i][j] = 1 + lcs[i - 1][j - 1];
      } else {
        lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
      }
    }
  }
  return lcs[s_len - 1][t_len - 1];
}

int main() {
  int n;
  cin >> n;
  string s, t;
  while (n--) {
    cin >> s >> t;
    int res = LCS(s, t);
    cout << res << endl;
  }
  return 0;
}


#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
map<char, vector<int>> alx, aly; // x,y
int memo[1010][1010];
string x, y, q;
int lcs(int xn, int yn) { // yn文字目以降でX[xn]と同じやつを探す
  if (memo[xn][yn] != -1)
    return memo[xn][yn];
  int ans = 0;
  /*
for(int i=xn; i<x.size();i++){
  for(int j=yn; j<y.size(); j++){
      if(alx[x[i]]==aly[y[j]]){
          ans=max(ans,lcs(i+1,j+1)+1);
      }
  }
}
  */
  for (int i = xn; i < x.size(); i++) {
    for (int j = 0; j < aly[x[i]].size(); j++) {
      if (aly[x[i]][j] < yn)
        continue;
      ans = max(ans, lcs(i + 1, aly[x[i]][j] + 1) + 1);
      break;
    }
  }
  return memo[xn][yn] = ans;
}

int main() {
  int q;
  cin >> q;
  for (int ds = 0; ds < q; ds++) {

    cin >> x >> y;
    for (int i = 0; i <= x.size(); i++) {
      for (int j = 0; j <= y.size(); j++) {
        memo[i][j] = -1;
      }
    }

    alx.clear();
    aly.clear();

    for (int i = 0; i < x.size(); i++)
      alx[x[i]].push_back(i);
    for (int i = 0; i < y.size(); i++)
      aly[y[i]].push_back(i);

    // memset(memo, -1, sizeof(memo));

    cout << lcs(0, 0) << endl;
  }
  return 0;
}

/*
int memo[1010][1010];
string x,y,q;
int lcs(int xn,int yn){//Y[yn]とX[xn]を比較
    if(memo[xn][yn]!=-1)return memo[xn][yn];
        else if(xn==0 || yn==0)return 0;
        else if(x[xn]==y[yn])return memo[xn][yn] = lcs(xn-1,yn-1)+1;
        else  return memo[xn][yn] = max(lcs(xn,yn-1),lcs(xn-1,yn));
}

int main(){
    int q;
    cin >> q;
    for(int ds=0; ds<q; ds++){

        cin >> x >> y;
        for(int i=0; i<=x.size(); i++){
            for(int j=0; j<=y.size(); j++)memo[i][j]=-1;
        }
        //memset(memo, -1, sizeof(memo));

        cout << max(lcs(x.size(),y.size()),0) << endl;

    }
    return 0;
}*/

/*

#include<algorithm>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int n,memo[50]={};

int fib(int n){
        if(memo[n]!=0)return memo[n];
        return memo[n]=fib(n-1)+fib(n-2);
}

int main(){

        cin >> n;
        memo[0]=1;
        memo[1]=1;
        for(int i=2; i<=n; i++)
                memo[i]=memo[i-1]+memo[i-2];
        cout << memo[n] << endl;
        return 0;
}
*/

/*
#include<queue>
using namespace std;
int n,A[2000],q;//A:0origin
int memo[2000][2000];

bool solve(int i,int m){//i番目以降のAを使ってmを作る
        if(m==0) return true;//０はどんなときも作れる
        if(i==n) return false;//すべて使ってもつくれない
        //すでにやってるときメモを返す
        if(memo[i][m]!=0){
                if(memo[i][m]==-1)return false;
                else return true;
        }
        //solve(i,m)  A[i]を使う solve(i+1,m-A[i]) || 使わない　solve(i+1,m)
        bool X=false;
        if(m-A[i]>=0 && solve(i+1,m-A[i])) X=true;
        else if(solve(i+1,m)) X = true;

        if(X)memo[i][m]=1;
        else memo[i][m]=-1;

         return X;

}

int main(){

        cin >> n;

        for(int i=0; i<n; i++) cin >> A[i];

        cin >> q;

        for(int i=0; i<q; i++){
                int m;
                cin >> m;
                for(int k=0; k<n; k++){
                        for(int j=0; j<n; j++) memo[k][j]=0;
                }

                if(solve(0,m))cout << "yes" << endl;
                else cout << "no" << endl;
        }

        return 0;
}

*/

/*
        bool dp[2000][2000];
        bool memo[2000][2000];//[順番][m-これまでの総和]

        bool solve(int now,int least){
                if(now == n) return false;//now>nならfalse
                else if(least == 0)return true;//least==0 >> true
                else if(memo[now][least])return dp[now][least];//already diside
   >> そのまま出来上がってるのを返す else if(solve(now+1,least))dp[now][least] =
   true;//A[now]をとらない >> solve(now++,least) else if(least-A[now] > 0 &&
   solve(now++,least-A[now]))dp[now][least] = true;//A[now]をとる
   (least-A[now]>0 only)>> solve(now++,least-A[now]) else dp[now][least] =
   false; memo[now][least] = true; return dp[now][least];
        }
        */

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define LL long long

string X, Y;
int q, Z;
int dp[1001][1001] = {};

int main() {
  cin >> q;
  for (int ds = 0; ds < q; ds++) {
    cin >> X >> Y;
    int xs = X.size(), ys = Y.size();
    for (int i = 0; i < xs; i++) {
      for (int j = 0; j < ys; j++) {
        int tmp = 0;
        if (X[i] == Y[j]) {
          if (i * j == 0)
            dp[i][j] = 1;
          else
            dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          if (i + j == 0)
            dp[0][0] = 0;
          else if (i == 0)
            dp[0][j] = dp[0][j - 1];
          else if (j == 0)
            dp[i][0] = dp[i - 1][0];
          else
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
      }
    }
    cout << dp[xs - 1][ys - 1] << endl;
  }
  return 0;
}


#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_LENGTH 1000
#define NIL -1
using namespace std;
// think easy make easy

int q; // num of datasets
string X;
string Y;
char map[MAX_LENGTH + 1][MAX_LENGTH + 1];

int findMaxLength(int x, int y) { // x:Xの終端.y:Yの終端(0オリジン)
  if (x < 0 || y < 0)
    return 0;
  if (map[x][y] == NIL) {
    if (X.at(x) == Y.at(y)) {
      return findMaxLength(x - 1, y - 1) + 1;
    } else {
      return max(findMaxLength(x - 1, y), findMaxLength(x, y - 1));
    }
  } else
    return map[x][y];
}

int main() {

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    cin >> X;
    cin >> Y;
    for (int i = 0; i < X.size(); i++) {
      for (int j = 0; j < Y.size(); j++) {
        map[i][j] = NIL;
      }
    }

    cout << findMaxLength(X.size() - 1, Y.size() - 1) << endl;
  }

  return 0;
}

#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_LENGTH 1000
#define NIL -1
using namespace std;
// think easy make easy

int q; // num of datasets
string X;
string Y;
int map[MAX_LENGTH + 1][MAX_LENGTH + 1];

int findMaxLength(int x, int y) { // x:Xの終端.y:Yの終端(0オリジン)
  int val;

  if (x < 0 || y < 0)
    return 0;

  if (map[x][y] == NIL) {
    if (X.at(x) == Y.at(y)) {
      val = findMaxLength(x - 1, y - 1) + 1;
    } else {
      val = max(findMaxLength(x - 1, y), findMaxLength(x, y - 1));
    }
    map[x][y] = val; // メモ
    return val;
  } else
    return map[x][y];
}

int main() {

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    cin >> X;
    cin >> Y;
    for (int i = 0; i < X.size(); i++) {
      for (int j = 0; j < Y.size(); j++) {
        map[i][j] = NIL;
      }
    }

    cout << findMaxLength(X.size() - 1, Y.size() - 1) << endl;
  }

  return 0;
}


#include <iostream>
#include <string>
#define int long long
// #define _DEBUG
using namespace std;
string sa, sb;
int T[1000][1000];
int solve() {
  int sal = sa.length(), sbl = sb.length();
  for (int a = 0; a <= sal; a++) {
    for (int b = 0; b <= sbl; b++) {
      if (a == 0 || b == 0) {
        T[a][b] = 0;
      } else if (sa[a - 1] == sb[b - 1]) {
        T[a][b] = 1 + T[a - 1][b - 1];
      } else {
        T[a][b] = max(T[a][b - 1], T[a - 1][b]);
      }
    }
  }
  return T[sal][sbl];
}
signed main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> sa >> sb;
    cout << solve() << endl;
  }
}

#include <iostream>
#include <string>
#define int long long
// #define _DEBUG
using namespace std;
string sa, sb;
int T[1009][1009];
int solve() {
  int sal = sa.length(), sbl = sb.length();
  for (int a = 0; a <= sal; a++) {
    for (int b = 0; b <= sbl; b++) {
      if (a == 0 || b == 0) {
        T[a][b] = 0;
      } else if (sa[a - 1] == sb[b - 1]) {
        T[a][b] = 1 + T[a - 1][b - 1];
      } else {
        T[a][b] = max(T[a][b - 1], T[a - 1][b]);
      }
    }
  }
  return T[sal][sbl];
}
signed main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> sa >> sb;
    cout << solve() << endl;
  }
}


#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <stack>
#include <stdio.h>
#include <string>
#define MAX 101
using namespace std;
int main() {
  int n;
  cin >> n;
  string x, y;
  int data[MAX][MAX] = {0, 0};
  for (int d = 0; d < n; d++) {
    cin >> x >> y;
    for (int i = 0; i < y.size(); i++) {
      for (int j = 0; j < x.size(); j++) {
        if (y[i] == x[j]) {
          data[j + 1][i + 1] = data[j][i] + 1;
        } else {
          data[j + 1][i + 1] = max(data[j + 1][i], data[j][i + 1]);
        }
      }
    }
    cout << data[x.size()][y.size()] << endl;
  }

  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <stack>
#include <stdio.h>
#include <string>
#define MAX 1001
using namespace std;
int main() {
  int n;
  cin >> n;
  string x, y;
  int data[MAX][MAX] = {0, 0};
  for (int d = 0; d < n; d++) {
    cin >> x >> y;
    for (int i = 0; i < y.size(); i++) {
      for (int j = 0; j < x.size(); j++) {
        if (y[i] == x[j]) {
          data[j + 1][i + 1] = data[j][i] + 1;
        } else {
          data[j + 1][i + 1] = max(data[j + 1][i], data[j][i + 1]);
        }
      }
    }
    cout << data[x.size()][y.size()] << endl;
  }

  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

void fnInput(vector<string> &rvsStrX, vector<string> &rvsStrY) {
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i) {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string> &cnrvsStrX,
                   const vector<string> &cnrvsStrY) {
  vector<vector<int>> vvnLcsDP;
  for (int i = 0; i < cnrvsStrX.size(); ++i) {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();

    vvnLcsDP.shrink_to_fit();
    vvnLcsDP.resize(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}


#include <stdio.h>
#include <string.h>

#define N 10000

int lcs(char *x, char *y) {
  int c[N + 1][N + 1];
  int m = strlen(x);
  int n = strlen(y);
  int maxl = 0;
  x = strcat(" ", x);
  y = strcat(" ", y);
  int i, j;
  for (i = 1; i <= m; i++) {
    c[i][0] = 0;
  }
  for (j = 0; j <= n; j++) {
    c[0][j] = 0;
  }

  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (x[i] == y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        if (c[i - 1][j] > c[i][j - 1])
          c[i][j] = c[i - 1][j];
        else
          c[i][j] = c[i][j - 1];
      }
      if (maxl > c[i][j])
        maxl = maxl;
      else
        maxl = c[i][j];
    }
  }
  return maxl;
}

int main() {
  char s1[1000];
  char s2[1000];
  int n;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%s%s", s1, s2);
    printf("%d\\n", lcs(s1, s2));
  }
  return 0;
}

#include <stdio.h>
#include <string.h>

#define M 1001

int n;

char x[M], y[M];

void lcs(void) {
  int i, j;
  int len_x, len_y, graph[M][M];

  len_x = strlen(x);
  len_y = strlen(y);
  for (i = 1; i < M; i++) {
    for (j = 1; j < M; j++) {
      graph[i][j] = 0;
    }
  }
  for (i = 1; i <= len_x; i++) {
    for (j = 1; j <= len_y; j++) {
      if (x[i - 1] == y[j - 1])
        graph[i][j] = graph[i - 1][j - 1] + 1;

      else {
        if (graph[i - 1][j] >= graph[i][j - 1])
          graph[i][j] = graph[i - 1][j];
        else
          graph[i][j] = graph[i][j - 1];
      }
    }
  }
  printf("%d\\n", graph[len_x][len_y]);
}

int main() {
  int i;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", x);
    scanf("%s", y);
    lcs();
  }
  return 0;
}


#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    string x, y;
    cin >> x >> y;
    int p = x.size();
    int q = y.size();
    int l[1000][1000] = {};
    for (int i = 1; i < p + 1; i++) {
      for (int j = 1; j < q + 1; j++) {
        if (x[i - 1] == y[j - 1]) {
          l[i][j] = 1 + l[i - 1][j - 1];
        } else {
          l[i][j] = max(l[i - 1][j], l[i][j - 1]);
        }
      }
    }
    cout << l[p][q] << endl;
  }
}

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    string x, y;
    cin >> x >> y;
    int p = x.size();
    int q = y.size();
    int l[1001][1001] = {};
    for (int i = 1; i < p + 1; i++) {
      for (int j = 1; j < q + 1; j++) {
        if (x[i - 1] == y[j - 1]) {
          l[i][j] = 1 + l[i - 1][j - 1];
        } else {
          l[i][j] = max(l[i - 1][j], l[i][j - 1]);
        }
      }
    }
    cout << l[p][q] << endl;
  }
}


#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; ++i)
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  string x, y;
  REP(i, q) {
    cin >> x >> y;
    int dp[x.size() + 1][y.size() + 1];
    fill(dp[0], dp[y.size()], -1);
    REP(j, x.size() + 1) {
      REP(k, y.size() + 1) {
        if (j == 0 || k == 0)
          dp[j][k] = 0;
        else if (x[j] == y[k])
          dp[j][k] = dp[j - 1][k - 1] + 1;
        else
          dp[j][k] = max(dp[j][k - 1], dp[j - 1][k]);
      }
    }
    printf("%d\\n", dp[x.size()][y.size()]);
  }
  return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; ++i)
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  string x, y;
  REP(i, q) {
    cin >> x >> y;
    int dp[x.size() + 1][y.size() + 1];
    fill(dp[0], dp[x.size()], -1);
    REP(j, x.size() + 1) dp[j][0] = 0;
    REP(j, y.size() + 1) dp[0][j] = 0;
    FOR(j, 1, x.size() + 1) {
      FOR(k, 1, y.size() + 1) {
        if (x[j - 1] == y[k - 1])
          dp[j][k] = dp[j - 1][k - 1] + 1;
        else
          dp[j][k] = max(dp[j][k - 1], dp[j - 1][k]);
      }
    }
    printf("%d\\n", dp[x.size()][y.size()]);
  }
  return 0;
}


#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

#define MAX 1000

int c[MAX][MAX];

int lcs(string A, string B) {
  int a = A.length();
  int b = B.length();
  int maxl = 0;

  A = ' ' + A;
  B = ' ' + B;
  // 配列を作る
  for (int i = 0; i < a; i++) {
    c[i][0] = 0;
  }
  for (int j = 0; j < b; j++) {
    c[0][j] = 0;
  }
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      if (A[i] == B[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

#define MAX 1000

int c[MAX + 1][MAX + 1];

int lcs(string A, string B) {
  int a = A.length();
  int b = B.length();
  int maxl = 0;

  A = ' ' + A;
  B = ' ' + B;
  // 配列を作る
  for (int i = 0; i < a; i++) {
    c[i][0] = 0;
  }
  for (int j = 0; j < b; j++) {
    c[0][j] = 0;
  }
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      if (A[i] == B[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int **c = (int **)malloc(sizeof(int *) * 1001);
  for (int i = 0; i < 1001; i++) {
    c[i] = (int *)malloc(sizeof(int) * 1001);
  }
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  c[0][0] = 0;
  for (int i = 1; i <= m; i++)
    c[i][0] = 0;
  for (int j = 1; j <= n; j++)
    c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int **c = (int **)malloc(sizeof(int *) * 1001);
  for (int i = 0; i < 1001; i++) {
    c[i] = (int *)malloc(sizeof(int) * 1001);
  }
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  c[0][0] = 0;
  for (int i = 1; i <= m; i++)
    c[i][0] = 0;
  for (int j = 1; j <= n; j++)
    c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  for (int i = 0; i < 1001; i++) {
    free(c[i]);
  }
  free(c);
  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#define FOR(i, b, e) for (int i = b; i < e; i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

string s1, s2;

int lcs(int n1, int n2) {
  if (n1 < 0 || n2 < 0)
    return 0;

  if (s1[n1] == s2[n2])
    return 1 + lcs(n1 - 1, n2 - 1);
  else
    return max(lcs(n1, n2 - 1), lcs(n1 - 1, n2));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int q;
  cin >> q;
  REP(i, q) {
    cin >> s1;
    cin >> s2;

    cout << lcs(s1.length() - 1, s2.length() - 1) << endl;
  }
}

#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#define FOR(i, b, e) for (int i = b; i < e; i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int dp[1001][1001];
string s1, s2;

int lcs(int n1, int n2) {
  if (dp[n1][n2] != -1)
    return dp[n1][n2];

  dp[n1][n2] = (s1[n1 - 1] == s2[n2 - 1])
                   ? (1 + lcs(n1 - 1, n2 - 1))
                   : max(lcs(n1 - 1, n2), lcs(n1, n2 - 1));
  return dp[n1][n2];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int q;
  cin >> q;
  REP(i, q) {
    REP(i, 1001) {
      REP(j, 1001) { dp[i][j] = -1; }
    }
    REP(i, 1001) dp[i][0] = 0;
    REP(i, 1001) dp[0][i] = 0;

    cin >> s1;
    cin >> s2;

    cout << lcs(s1.length(), s2.length()) << endl;
  }
}


#include <iostream>
#include <vector>
using namespace std;

#define MAX_N (1e9) + 1

int main(void) {
  //?????????????????????
  vector<bool> eratos(MAX_N, true);
  eratos[0] = eratos[1] = false;
  for (int i = 2; i * i < MAX_N; i++)
    if (eratos[i])
      for (int j = 2; i * j < MAX_N; j++)
        eratos[i * j] = false;

  //?????¨?????????
  int n, input, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    if (eratos[input])
      ++ans;
  }

  //??????
  cout << ans << endl;
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

#define MAX_N (1e8) + 1

int main(void) {
  //?????????????????????
  vector<bool> eratos(MAX_N, true);
  eratos[0] = eratos[1] = false;
  for (int i = 2; i * i < MAX_N; i++)
    if (eratos[i])
      for (int j = 2; i * j < MAX_N; j++)
        eratos[i * j] = false;

  //?????¨?????????
  int n, input, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    if (eratos[input])
      ++ans;
  }

  //??????
  cout << ans << endl;
  return 0;
}


#include <iostream>

using namespace std;

int pn(int num) {

  if (num == 2 || num == 3 || num == 5)
    return 1;
  if (num < 2 || num % 2 == 0)
    return 0;

  int i = 3;
  while (i < num - 1) {
    if (num % i == 0)
      return 0;
    i += 2;
  }
  return 1;
}

int main() {

  int n;
  int num;
  int cnt = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    cnt += pn(num);
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

int pn(int num) {

  if (num == 2 || num == 3 || num == 5)
    return 1;
  if (num < 2 || num % 2 == 0)
    return 0;

  int i = 3;
  while (i <= sqrt(num)) {
    if (num % i == 0)
      return 0;
    i += 2;
  }
  return 1;
}

int main() {

  int n;
  int num;
  int cnt = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    cnt += pn(num);
  }

  cout << cnt << endl;

  return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

int isPrime(long x);

int main() {
  long N, x;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    isPrime(x);
  }
  return 0;
}

int isPrime(long x) {
  bool prime;
  int i;
  if (x == 1) {
    prime = false;
  } else if (x == 2) {
    prime = true;
  } else if ((x % 2) == 0) {
    prime = false;
  } else if ((x % 2) != 0) {
    while (i <= sqrt(x)) {
      if ((x % i) == 0) {
        prime = false;
        break;
      } else {
        prime = true;
      }
      i = i + 2;
    }
  }
  if (prime) {
    cout << x << endl;
  }
  return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

bool isPrime(int x);

int main() {
  int N, x, cnt = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (isPrime(x)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

bool isPrime(int x) {
  bool prime = false;
  int i = 3;
  if (x == 1) {
  } else if ((x == 2) || (x == 3)) {
    prime = true;
  } else if ((x % 2) == 0) {
  } else {
    while (i < x) {
      if ((x % i) == 0) {
        break;
      } else if (i > sqrt(x)) {
        prime = true;
        break;
      }
      i = i + 2;
    }
  }
  return prime;
}


#include <iostream>
using namespace std;

int main(void) {
  int n, cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    long num;
    bool flag = true;

    cin >> num;

    for (int j = 2; j <= num / 2 && flag == true; j++) {
      if (num % j == 0) {
        flag = false;
        break;
      }
    }

    if (flag == true || num == 2)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
  int n, cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    long num;
    bool flag = true;

    cin >> num;

    for (int j = 2; j <= (int)sqrt((double)num) && flag == true; j++) {
      if (num % j == 0) {
        flag = false;
        break;
      }
    }

    if (flag == true || num == 2)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int n, num;
  int notpr;

  cin >> n;

  notpr = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    for (int j = 2; j < num; j++) {
      if (num % j == 0) {
        notpr++;
        break;
      }
    }
  }
  cout << n - notpr << endl;
}

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n, num;
  int notpr;

  cin >> n;

  notpr = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    for (int j = 2; j <= sqrt(num); j++) {
      if (num % j == 0) {
        notpr++;
        break;
      }
    }
  }
  cout << n - notpr << endl;
}


#include <iostream>
#define MAX 100000001
using namespace std;
bool isP[MAX];
void make_table() {
  for (int i = 0; i < MAX; i++)
    isP[i] = true;
  isP[0] = isP[1] = false;
  for (int i = 2; i * i < MAX; i++) {
    if (!isP[i])
      continue;
    for (int j = i * i; j < MAX; j += i) {
      isP[j] = false;
    }
  }
}

int main() {
  make_table();
  int n, a, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    cnt += isP[a];
  }
  cout << cnt << endl;
}

#include <iostream>
using namespace std;

bool isP(int x) {
  if (x == 0 || x == 1)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n, a, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    cnt += isP(a);
  }
  cout << cnt << endl;
}


#include <iostream>
using namespace std;

bool sieve[100000001];
void makeSieve() {
  fill_n(sieve, 100000001, true);
  sieve[0] = sieve[1] = false;
  for (int i = 4; i < 10001; i += 2) {
    sieve[i] = false;
  }
  for (int i = 3; i < 101; i += 2) {
    if (!sieve[i])
      continue;
    for (int j = i * i; j < 10001; j += i) {
      sieve[j] = false;
    }
  }
}
int main() {
  makeSieve();
  int n;
  cin >> n;
  int num = 0;
  while (n--) {
    int a;
    cin >> a;
    num += (int)sieve[a];
  }
  cout << num << endl;
  return 0;
}

#include <bitset>
#include <iostream>
using namespace std;

bitset<100000001> sieve;
void makeSieve() {
  sieve.set();
  sieve[0] = sieve[1] = false;
  for (int i = 4; i < 100000001; i += 2) {
    sieve[i] = false;
  }
  for (int i = 3; i < 10001; i += 2) {
    if (!sieve[i])
      continue;
    for (int j = i * i; j < 100000001; j += i) {
      sieve[j] = false;
    }
  }
}
int main() {
  makeSieve();
  int n;
  cin >> n;
  int num = 0;
  while (n--) {
    int a;
    cin >> a;
    num += (int)sieve[a];
  }
  cout << num << endl;
  return 0;
}


#include <iostream>
using namespace std;

bool check(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int n[10000];

int main() {
  int sw = 0;
  int a;
  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> n[i];
  }

  for (int i = 0; i < a; i++) {
    if (n[i] == 2) {
      sw++;
      continue;
    }
    if (check(n[i]))
      sw++;
  }
  cout << sw << endl;

  return 0;
}

#include <iostream>
using namespace std;

bool check(int n) {
  if (n < 2)
    return false;
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return false;

  int i;
  for (i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int n[10000];

int main() {
  int sw = 0;
  int a;
  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> n[i];
  }

  for (int i = 0; i < a; i++) {
    if (check(n[i]))
      sw++;
  }
  cout << sw << endl;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, i, j, a, b = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    for (j = 3; j < a; j = j + 2) {
      if (a % j == 0)
        break;
      if (a % 2 == 0)
        break;
      if (a % 3 == 0)
        break;
      if (a % 5 == 0)
        break;
      if (a % 7 == 0)
        break;
      if (j == a - 2)
        b++;
    }
    if (a == 2)
      b++;
    if (a == 3)
      b++;
    if (a == 5)
      b++;
    if (a == 7)
      b++;
  }
  cout << b << endl;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

bool isprime(int a) {
  if (a == 2)
    return true;
  if (a % 2 == 0)
    return false;
  for (int i = 3; i * i <= a; i += 2) {
    if (a % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n, j, b, sum = 0;
  cin >> n;
  for (j = 0; j < n; j++) {
    cin >> b;
    if (isprime(b))
      sum += 1;
  }
  cout << sum << endl;
}


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

bool is_prime(int num) {
  for (int i = 2; i < num; i++) {

    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
int main(void) {
  int n;
  cin >> n;

  int num;
  int prime_count = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;

    if (is_prime(num) == true) {
      prime_count++;
    }
  }
  cout << prime_count << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

bool is_prime(int num) {
  int a = sqrt(num);

  for (int i = 2; i <= a; i++) {

    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
int main(void) {
  int n;
  cin >> n;

  int num;
  int prime_count = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;

    if (is_prime(num) == true) {
      prime_count++;
    }
  }
  cout << prime_count << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int a[10001];
int main() {
  int n, b, c, m = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      continue;
    else {
      int t = 0;
      b = sqrt(a[i]);
      for (int j = 2; j <= b; j++)
        if (a[i] % j == 0)
          t++;
      if (t == 0)
        m++;
    }
  }
  printf("%d\\n", m);
  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
vector<int> n;
vector<int> solute(vector<bool> *p) {
  int count = (*p).size();
  for (int i = 2; i * i < count; i++) {
    if (!(*p).at(i)) {

      for (int j = i; j * i < count; j++) {
        (*p)[i * j] = true;
      }
    }
  }
}
int main(void) {
  int count, temp, ans = 0;

  cin >> count;
  for (int i = 0; i < count; i++) {
    cin >> temp;
    n.push_back(temp);
  }
  sort(n.begin(), n.end());
  vector<bool> pri(n.back() + 1, 0);
  solute(&pri);

  for (int i = 0; i < count; i++) {
    if (!pri.at(n.at(i)))
      ans++;
  }

  cout << ans << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
vector<int> n;

int main(void) {
  int count, temp, ans = 0, rant = 0;

  cin >> count;
  for (int i = 0; i < count; i++) {
    cin >> temp;
    rant = rant > temp ? rant : temp;
    n.push_back(temp);
  }

  vector<bool> pri(++rant, 0);

  for (int i = 2; i * i < rant; i++) {
    if (!pri.at(i)) {

      for (int j = i; j * i < rant; j++) {
        pri[i * j] = true;
      }
    }
  }

  for (int i = 0; i < count; i++) {
    if (!pri.at(n.at(i)))
      ans++;
  }

  cout << ans << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

typedef long long ll;

using namespace std;

bool isPrime(int x) {
  if (x == 2)
    return true;
  if (x < 2 || x % 2 == 0)
    return false;

  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  while (n--) {
    int t;
    cin >> t;

    if (isPrime(t)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[1000];
int n;
int main() {
  cin >> n;
  int x, cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    int k = 0;
    for (int j = 1; j <= x; ++j)
      if (x % j == 0)
        k++;
    if (k == 2)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;
bool f(int n) {
  int cnt = 0;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0)
      cnt++;
  }
  if (cnt == 0)
    return true;
  return false;
}
int main() {
  int n, m, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    if (f(m))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


#include <cmath>
#include <iostream>
using namespace std;
string prime(int a) {
  for (int j = 0; j < sqrt(a); j++) {
    if (a % j == 0) {
      return "no";
    }
  }
  return "yes";
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (prime(a[i]) == "yes") {
      cnt++;
    }
  }
  cout << cnt << "\\n";
  return 0;
}

#include <iostream>
using namespace std;
int n, k, t = 0;
bool prime(int o) {
  if (o < 2)
    return false;
  for (int i = 2; i * i <= o; i++)
    if (o % i == 0)
      return false;
  return true;
}
int main() {
  cin >> n;
  while (n--) {
    cin >> k;
    if (prime(k))
      t++;
  }
  cout << t << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
// #define Kongxiangzhouye
#define sd(x) scanf("%d", &x)
#define ss(x) scanf("%s", x)
#define sc(x) scanf("%c", &x)
#define sf(x) scanf("%f", &x)
#define slf(x) scanf("%lf", &x)
#define slld(x) scanf("%lld", &x)
#define me(x, b) memset(x, b, sizeof(x))
#define pd(d) printf("%d\\n", d);
#define plld(d) printf("%lld\\n", d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N = 100000;
const int INF = 0x3f3f3f3f;

bool vis[100000000];
int main() {
#ifdef Kongxiangzhouye
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  memset(vis, 0, sizeof(vis));
  int m = sqrt(100000000);
  for (int i = 2; i < m; i++) {
    if (!vis[i])
      for (int j = i * 2; j < 100000000; j = j + i)
        vis[j] = 1;
  }
  int n, a;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (!vis[a])
      ans++;
  }
  cout << ans << endl;

  return 0;
}

#include <stdio.h>

bool is_prime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;
  return true;
}

int main() {
  int N, n, k = 0;
  scanf("%d", &N);
  while (N--) {
    scanf("%d", &n);
    if (is_prime(n))
      k++;
  }
  printf("%d\\n", k);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, l, p = 0, q = 0;
  long long k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> k;
    p = 0;
    for (j = 2; j <= k / 2; j++) {
      if ((k % j) == 0) {
        p = 1;
        break;
      }
    }
    if (p == 0) {
      q++;
    }
  }
  cout << q << '\\n';
  ;
}

#include <cmath>
#include <cstdio>
bool isp(int nu) {
  int i = 1;
  if (nu == 1)
    return false;
  else if (nu == 2)
    return 1;
  int sqr = sqrt(nu) + 1;
  for (i = 2; i <= sqr; i++)
    if (nu % i == 0)
      return false;
  return true;
}
int main() {
  short sum = 0, n;
  scanf("%d", &n);
  for (; n > 0; n--) {
    int temp;
    scanf("%d", &temp);
    if (isp(temp))
      sum++;
  }
  printf("%d\\n", sum);
}


#include <iostream>
using namespace std;
bool isPrime(int text) {
  if (text == 1)
    return 0;
  for (int i = 2; i < (text - i) + 1; i++) {
    if (text % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int n; // 测试个数
  cin >> n;
  int nub = 0; // 质数个数
  while (n--) {
    int text;
    cin >> text;
    if (isPrime(text)) {
      nub++;
    }
  }
  cout << nub << endl;
  return 0;
}

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main() {
  int n, i, j, pnum = 0;
  int l;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &l);
    for (j = 2; j <= sqrt(l) && (int)l % j != 0; j++)
      ;
    if (j == (int)sqrt(l) + 1 || l == 2 || l == 3 || l == 5 || l == 7)
      pnum++;
  }
  printf("%d\\n", pnum);
  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int n, i, j, x, total = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x == 2 | x == 3)
      total++;
    for (j = 2; j <= x / 2; j++) {
      if (x % j == 0)
        break;
      if (j == x / 2)
        total++;
    }
  }
  cout << total << endl;
}

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n, i, j, x, total = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x == 2)
      total++;
    if (x % 2 != 0) {
      for (j = 3; j <= (double)sqrt(x); j += 2) {
        if (x % j == 0)
          goto a;
      }
      total++;
    a:;
    }
  }
  cout << total << endl;
}


#include <iostream>
#include <math.h>
using namespace std;

unsigned char prime[100000000];
int main() {
  int primeTop;
  int n;
  int num, count = 0;

  for (int i = 0; i < 100000000; i++) {
    prime[i] = '2';
  }
  prime[0] = prime[1] = '0';
  for (int i = 0; i < sqrt(100000000); i++) {
    if (prime[i] == '2') {
      primeTop = i;
      for (int j = 1; primeTop * j < 100000000; j++) {
        prime[j * primeTop] = '0';
      }
      prime[primeTop] = '1';
    }
  }

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (prime[num] == '1')
      count++;
  }

  cout << count << endl;

  return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

bool isprime(int x) {
  if (x == 2)
    return true;
  if (x < 2 || x % 2 == 0) {
    return false;
  }

  for (int i = 3; i <= sqrt(x); i += 2) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int main() {
  int n;
  int num;
  int count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (isprime(num))
      count++;
  }

  cout << count << endl;

  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int n, num, ans = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    int j = 2;
    if (num == 2)
      ans++;
    else {
      while (j <= num) {
        if (num % j == 0)
          break;
        if (j == num - 1)
          ans++;
        j++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

int main() {
  int n, num, ans = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    int j = 2;
    if (num == 2 || num == 3)
      ans++;
    else {
      while (j <= (int)sqrt(num)) {

        if ((num % j) == 0)
          break;
        if (j == (int)sqrt(num))
          ans++;

        j++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


#include <iostream>

using namespace std;

bool isPrime(int *list, int n, int c) {
  if (n == 2) {
    return true;
  }
  for (int i = 0; i < c; i++) {
    if (n % list[i] == 0)
      return false;
  }
  return true;
}

int main() {
  int n, c = 0, v;
  cin >> n;
  int m[n];
  for (int i = 0; i < n; i++) {
    cin >> v;
    if (isPrime(m, v, c)) {
      c++;
      m[c] = v;
    }
  }
  cout << c << endl;
  return 0;
}

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

#define PMAX (1e8) + 1

int main() {
  vector<bool> p(PMAX, true);
  p[0] = p[1] = false;
  for (int i = 2; i * i < PMAX; i++) {
    if (p[i]) {
      for (int j = 2; i * j < PMAX; j++)
        p[i * j] = false;
    }
  }

  int n, input, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> input;
    if (p[input])
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 25
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

bool isPrime(int n) {
  REP(i, 2, n) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int count = 0;
  int n, num;
  cin >> n;
  rep(i, n) {
    cin >> num;
    if (isPrime(num)) {
      count++;
    }
  }
  P(count);
  return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 25
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

bool *isprime;

bool isPrime(int n) {
  if (n == 1) {
    return false;
  }
  if (n == 2) {
    return true;
  }
  if (n > 2 && n % 2 == 0) {
    return false;
  }
  int i = 3;
  while (i <= (int)sqrt(n)) {
    if (n % i == 0) {
      return false;
    }
    i += 2;
  }
  return true;
}

int main() {
  int count = 0;
  int n, num;
  cin >> n;
  rep(i, n) {
    cin >> num;
    if (isPrime(num)) {
      count++;
    }
  }
  P(count);
  return 0;
}


#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

bool *sieve;
int limit;
void makeSieve() {
  fill_n(sieve, limit + 1, true);
  sieve[0] = sieve[1] = false;
  for (int i = 4; i < limit + 1; i += 2) {
    sieve[i] = false;
  }
  for (int i = 3; i < sqrt(limit + 1); i += 2) {
    if (!sieve[i])
      continue;
    for (int j = i * i; j < limit + 1; j += i) {
      sieve[j] = false;
    }
  }
}
int main() {
  int n;
  cin >> n;

  vector<int> elements;
  limit = 0;
  while (n--) {
    int tmp;
    cin >> tmp;
    elements.push_back(tmp);
    limit = max(limit, tmp);
  }

  sieve = new bool[limit + 1];
  makeSieve();

  int num = 0;
  for (int i = 0; i < (int)elements.size(); ++i) {
    num += (int)sieve[elements[i]];
  }
  cout << num << endl;

  delete[] sieve;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;

bool isPrime(int n) {
  if (n <= 1)
    return false;
  for (int i = 2, l = (int)sqrt(n); i <= l; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int num = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    num += isPrime(x);
  }
  cout << num << endl;
  return 0;
}


#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define int ll
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (ll i = (ll)(b)-1; i >= a; --i)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9 + 7;
void cioacc() { // accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
pair<vl, vb> eratosthenes_sieve(ll n) {
  vb is_prime(n + 1, true);
  vl prime;
  is_prime[0] = false;
  is_prime[1] = false;
  FOR(i, 2, n + 1) {
    if (!is_prime[i])
      continue;
    for (ll j = 2 * i; j <= n; j += i)
      is_prime[j] = false;
    prime.eb(i);
  }
  return {prime, is_prime};
}
signed main() {
  int n;
  cin >> n;
  vb isp = eratosthenes_sieve(1e8).second;
  int ans = 0;
  REP(i, n) {
    int a;
    cin >> a;
    if (isp[a])
      ans++;
  }
  cout << ans << endl;
}

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7 + (1e+9);

int main() {
  ll N = 100000000;
  vector<ll> v(10000000, 0);
  vector<bool> is_prime(N + 1, true);
  ll ii = 0;
  for (ll p = 2; p <= N; p++) {
    if (!is_prime[p])
      continue;
    // p の倍数を全て消す。
    for (ll k = p * 2; k <= N; k += p)
      is_prime[k] = false;
    v[ii] = p;
    ii++;
  }
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll z;
    cin >> z;
    if (is_prime[z])
      ans++;
  }
  cout << ans << endl;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

const int P_MAX = 1e8;

int main() {
  vector<int> isPrime(P_MAX + 1, 1);
  isPrime[0] = isPrime[1] = 0;

  for (int i = 4; i <= P_MAX; i += 2) {
    isPrime[i] = 0;
  }
  int limit = sqrt(P_MAX);
  for (int i = 3; i <= limit; i += 2) {
    if (!isPrime[i]) {
      continue;
    }
    for (int j = i * 2; j <= P_MAX; j += i) {
      isPrime[j] = 0;
    }
  }

  int n, m;
  scanf("%d", &n);
  int count = 0;

  for (int i = 0; i < n; i++) {
    scanf("%d", &m);
    count += isPrime[m];
  }
  printf("%d\\n", count);
  return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

const int P_MAX = 1e6;

int main() {
  vector<bool> isPrime(P_MAX + 1, true);
  vector<int> primes(P_MAX / 2, 0);
  isPrime[0] = isPrime[1] = 0;

  for (int i = 4; i <= P_MAX; i += 2) {
    isPrime[i] = false;
  }
  int limit = sqrt(P_MAX);
  for (int i = 3; i <= limit; i += 2) {
    if (!isPrime[i]) {
      continue;
    }
    for (int j = i * 2; j <= P_MAX; j += i) {
      isPrime[j] = false;
    }
  }

  primes[0] = 2;
  int n_p = 1;
  for (int i = 3; i <= P_MAX; i += 2) {
    if (isPrime[i]) {
      primes[n_p] = i;
      n_p++;
    }
  }

  int n, m;
  scanf("%d", &n);
  int count = 0;

  for (int i = 0; i < n; i++) {
    scanf("%d", &m);
    if (m <= P_MAX) {
      count += isPrime[m] ? 1 : 0;
    } else {
      int limit = sqrt(m);
      ;
      bool ok = true;
      for (int j = 0; j < n_p; j++) {
        if (primes[j] > limit) {
          break;
        }
        if (m % primes[j] == 0) {
          ok = false;
          break;
        }
      }
      if (ok) {
        count++;
      }
    }
  }
  printf("%d\\n", count);
  return 0;
}


#include <iostream>

using namespace std;

class PrimeNumbers {
public:
  int solve(int n, int a[]);
  bool isPrime(int x);
};

int PrimeNumbers::solve(int n, int a[]) {
  int result = 0;

  for (int i = 0; i < n; i++) {
    if (isPrime(a[i]))
      result++;
  }
  return result;
}

bool PrimeNumbers::isPrime(int x) {
  if (x == 2)
    return true;

  for (int i = 2; i < x; i++) {
    if ((x % i) == 0)
      return false;
  }
  return true;
}

int main(void) {
  int n;
  int a[10000];

  PrimeNumbers *pn = new PrimeNumbers();

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> a[i];

  cout << pn->solve(n, a) << endl;

  delete pn;

  return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

class PrimeNumbers {
public:
  int solve(int n, int a[]);
  bool isPrime(int x);
};

int PrimeNumbers::solve(int n, int a[]) {
  int result = 0;

  for (int i = 0; i < n; i++) {
    if (isPrime(a[i]))
      result++;
  }
  return result;
}

bool PrimeNumbers::isPrime(int x) {
  if (x == 2)
    return true;

  for (int i = 2; i <= sqrt(x); i++) {
    if ((x % i) == 0)
      return false;
  }
  return true;
}

int main(void) {
  int n;
  int a[10000];

  PrimeNumbers *pn = new PrimeNumbers();

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> a[i];

  cout << pn->solve(n, a) << endl;

  delete pn;

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string.h>
#include <string>
#include <vector>

#define N 1000000

using namespace std;

bool arr[N];
int cnt = 0;

void Eratosthenes(int n);

int main() {
  int n, input;
  cin >> n;
  Eratosthenes(N);
  for (int i = 0; i < n; i++) {
    cin >> input;
    if (arr[input])
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

void Eratosthenes(int n) {
  for (int i = 0; i < n; i++) {
    arr[i] = 1;
  }
  for (int i = 2; i < sqrt(n); i++) {
    if (arr[i]) {
      for (int j = 0; i * (j + 2) < n; j++) {
        arr[i * (j + 2)] = 0;
      }
    }
  }
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string.h>
#include <string>
#include <vector>

#define N 1000000

using namespace std;

bool isPrime(int x) {
  if (x == 2)
    return true;
  if (x % 2 == 0)
    return false;

  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return false;
  }

  return true;
}

int main() {
  int n, cnt = 0, input;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> input;

    if (isPrime(input))
      cnt++;
  }

  cout << cnt << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define N 100000002
int prime[N];

void seive() {
  memset(prime, 1, sizeof(prime));
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 0; i * i <= N; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j < N; j += i)
        prime[j] = 0;
    }
  }
}

int check_prime(int num) {
  if (num == 2)
    return 1;
  if (!num & 1)
    return 0;
  else
    return prime[num];
}

int main() {
  // FILE *inp = freopen("in.txt", "r", stdin);
  int n;
  cin >> n;
  int num[n];
  int prime_cnt = 0;
  seive();
  for (int i = 0; i < n; ++i) {
    cin >> num[i];
    if (check_prime(num[i]))
      prime_cnt++;
  }
  cout << prime_cnt << endl;
  // fclose(inp);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define N 10010
vector<int> prime_list;

void seive() {
  int prime[N];
  memset(prime, 1, sizeof(prime));
  prime_list.clear();
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 0; i * i <= N; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j < N; j += i)
        prime[j] = 0;
    }
  }
  for (int i = 0; i < N; ++i)
    if (prime[i])
      prime_list.push_back(i);
}

int check_prime(int num) {
  if (num == 2)
    return 1;
  if (!num & 1)
    return 0;

  int state = 1;
  int size = prime_list.size();
  for (int i = 0; i < size && prime_list[i] * prime_list[i] <= num; ++i) {
    if (!(num % prime_list[i])) {
      return 0;
    }
  }
  return 1;
}

int main() {
  // FILE *inp = freopen("in.txt", "r", stdin);
  int n, num;
  int prime_cnt = 0;
  seive();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    if (check_prime(num)) {
      prime_cnt++;
    }
  }
  cout << prime_cnt << endl;
  // fclose(inp);
  return 0;
}


#include <cmath>
#include <iostream>
using namespace std;

bool prime[100000001];

int main() {
  int endi = (int)sqrt(100000000);
  for (int i = 2; i <= endi; i++) {
    if (!prime[i]) {
      for (int j = i + i; j <= 100000000; j += i) {
        prime[j] = true;
      }
    }
  }
  int n, count = 0;
  cin >> n;
  while (n--) {
    int k;
    cin >> k;
    if (!prime[k])
      count++;
  }
  cout << count << endl;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int n, count = 0;
  cin >> n;
  while (n--) {
    bool prime = true;
    int k, endk;
    cin >> k;
    endk = (int)sqrt(k);
    for (int i = 2; i <= endk; i++) {
      if (k % i == 0) {
        prime = false;
        break;
      }
    }
    if (prime)
      count++;
  }
  cout << count << endl;
  return 0;
}


#include <iostream>

int num[10000000] = {0};

void func(int n) {
  for (int i = 2; i <= n; ++i) {
    bool f = true;
    for (int j = 2; j * j <= i; ++j) {
      if (i % j == 0)
        f = false;
    }
    if (f)
      num[i] = 1;
    else
      num[i] = 0;
  }
}

int main() {
  int n;
  std::cin >> n;
  int ans = 0;
  func(10000000);
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    if (num[a] == 1) {
      ans++;
    }
    // std::cout << num[i] << std::endl;
  }
  std::cout << ans << std::endl;
  return 0;
}

#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    bool f = true;
    for (int j = 2; j * j <= a; ++j) {
      if (a % j == 0)
        f = false;
    }
    if (f)
      ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


#include <cmath>
#include <iostream>
#include <vector>

bool is_prime(int a);

int main() {
  int n;
  int cnt = 0;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    bool flag = is_prime(a[i]);
    if (flag)
      cnt++;
  }
  std::cout << cnt << '\\n';
  return 0;
}

bool is_prime(int a) {
  for (int i = 0; i < std::sqrt(a); i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}

#include <cmath>
#include <iostream>
#include <vector>

bool is_prime(int a);

int main() {
  int n;
  int cnt = 0;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    bool flag = is_prime(a[i]);
    if (flag)
      cnt++;
  }
  std::cout << cnt << '\\n';
  return 0;
}

bool is_prime(int a) {
  if (a == 2) {
    return true;
  } else if (a == 0 || a == 1) {
    return false;
  }
  for (int i = 2; i <= std::sqrt(a); i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool is_prime(int n) {
  // naive program
  int p = 2;
  while (p < n) {
    if (n % p == 0) {
      return false;
    }
    p++;
  }
  return true;
}

int main() {
  int N;
  int cnt = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    if (is_prime(n)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

#include <algorithm>
#include <iostream>
using namespace std;

bool is_prime(int n) {
  // naive program
  int p = 2;
  while (p * p <= n) {
    if (n % p == 0) {
      return false;
    }
    p++;
  }
  return true;
}

int main() {
  int N;
  int cnt = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    if (is_prime(n)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


#include <iostream>
using namespace std;

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

bool isPrime(int x) {
  if (x <= 1)
    return false;
  if (x % 2 == 0 && x != 2)
    return false;
  for (int i = 3; i <= x / 2; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (isPrime(x)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>
using namespace std;

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

bool isPrime(int x) {
  if (x <= 1)
    return false;
  if (x % 2 == 0 && x != 2)
    return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (isPrime(x)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


#include <iostream>
using namespace std;

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

bool isPrime(int x) {
  if (x == 1)
    return false;
  for (int i = 2; i < x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (isPrime(x)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>
using namespace std;

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

bool isPrime(int x) {
  if (x == 1)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (isPrime(x)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


#include <iostream>
using namespace std;
bool prime[20001];

int main() {
  prime[0] = prime[1] = 1;
  for (int i = 2; i * i <= 10000; i++)
    for (int j = 2; j <= 10000 / i && prime[i] == 0; j++)
      prime[j * i] = 1;

  int n, ans = 0;
  cin >> n;
  while (n--) {
    int a;
    cin >> a;
    if (!prime[a])
      ans++;
  }
  cout << ans << endl;
}

#include <iostream>
using namespace std;

int main() {

  int n, ans = 0;
  cin >> n;
  while (n--) {
    int a;
    cin >> a;
    int i = 2;
    while (i * i <= a && a % i)
      i++;
    if (a % i || a == 2)
      ans++;
  }
  cout << ans << endl;
}


#include <cmath>
#include <iostream>

using namespace std;
bool f(int a) {
  bool F = 1;
  for (int i = 2; i < sqrt(a * 1.0) + 1; i++) {
    if (a % i == 0 && a != 2)
      F = 0;
  }
  return F;
};

int main() {
  int n, x = 0;
  int a[10000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (f(a[i]))
      x++;
  }
  cout << x << endl;
  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, count = 0;
  vector<int> N;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    int j;
    cin >> j;
    N.push_back(j);
  }

  for (int i = 0; i < n; ++i) {
    bool flag = true;

    for (int j = 2; j < N[i]; ++j) {
      if (N[i] % j == 0) {
        flag = false;
      }
    }

    if (flag)
      ++count;
  }

  cout << count << endl;

  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int IsPrime(int n) {
  int i;

  if (n < 2)
    return 0;
  else if (n == 2)
    return 1;

  if (n % 2 == 0)
    return 0;

  for (i = 3; i * i <= n; i += 2)
    if (n % i == 0)
      return 0;
  return 1;
}

int main() {
  int n, count = 0;
  vector<int> N;

  cin >> n;

  for (int i = 0; i < n; ++i) {
    int j;
    cin >> j;

    bool flag = true;
    for (int k = 0; k < N.size(); ++k) {
      if (j == N[k]) {
        flag = false;
        break;
      }
    }

    if (flag)
      N.push_back(j);
  }

  for (int i = 0; i < n; ++i) {
    if (IsPrime(N[i]))
      ++count;
  }

  cout << count << endl;

  return 0;
}


#include <iostream>
using namespace std;
#define rep(i, k, n) for (int i = k; i < n; i++)
#define MAX 10000001

bool is[MAX];
int main() {

  rep(i, 0, MAX) is[i] = true;
  is[0] = is[1] = 0;
  rep(i, 2, MAX) {
    if (is[i]) {
      for (int j = 2; i * j < MAX; j++) {
        is[i * j] = false;
      }
    }
  }
  int n, p, ans = 0;
  cin >> n;

  rep(i, 0, n) {
    cin >> p;
    if (is[p])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;
#define rep(i, k, n) for (int i = k; i < n; i++)
#define MAX 10000001

bool is[MAX];

// n log log n
// 10^8
void era() {
  rep(i, 0, MAX) is[i] = true;
  is[0] = is[1] = 0;
  rep(i, 2, MAX) {
    if (is[i]) {
      for (int j = 2; i * j < MAX; j++) {
        is[i * j] = false;
      }
    }
  }
}

int main() {
  // N root(n)
  // 10^4 10^4
  int n, p, ans = 0;
  cin >> n;

  rep(i, 0, n) {
    cin >> p;
    bool ex = true;
    if ((p % 2 == 0 && p != 2) || p == 1)
      continue;
    for (int j = 3; j <= sqrt(p); j += 2) {

      if (p % j == 0)
        ex = false;
    }
    if (ex)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


#include <cmath>
#include <iostream>
using namespace std;

int prs[5000];
int pri = 1;

int isPrime(int a) {
  int flg;
  if (sqrt(a) > prs[pri]) {
    for (int i = prs[pri] + 2; i <= sqrt(a); i += 2) {
      flg = 1;
      for (int j = 0; j <= pri; j++) {
        if (sqrt(i) < prs[i])
          break;
        if (i % prs[j] == 0) {
          flg = 0;
          break;
        }
      }
      if (flg)
        prs[++pri] = i;
    }
    // for (int i=0;i<=pri;i++)cout << prs[i] << " ";
  }
  for (int i = 0; i <= pri; i++) {
    if (sqrt(a) < prs[i])
      break;
    if (a % prs[i] == 0)
      return 0;
  }
  return 1;
}

int main() {
  prs[0] = 2;
  prs[1] = 3;

  int n, a, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    cnt += isPrime(a);
  }
  cout << cnt << endl;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;

int prs[10000];
int pri = 1;

int isPrime(int a) {
  int flg;
  if (sqrt(a) > prs[pri]) {
    for (int i = prs[pri] + 2; i <= sqrt(a); i += 2) {
      flg = 1;
      for (int j = 0; j <= pri; j++) {
        if (sqrt(i) < prs[i])
          break;
        if (i % prs[j] == 0) {
          flg = 0;
          break;
        }
      }
      if (flg)
        prs[++pri] = i;
    }
    // for (int i=0;i<=pri;i++)cout << prs[i] << " ";
  }
  for (int i = 0; i <= pri; i++) {
    if (sqrt(a) < prs[i])
      break;
    if (a % prs[i] == 0)
      return 0;
  }
  return 1;
}

int main() {
  prs[0] = 2;
  prs[1] = 3;

  int n, a, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    cnt += isPrime(a);
  }
  cout << cnt << endl;
  return 0;
}


#include <iostream>
using namespace std;

int isPrime(int num) {
  int i;
  if (num <= 1)
    return 0;

  else if (num == 2)
    return 1;
  if (num % 2 == 0)
    return 0;

  for (i = 3; i < num; i += 2) {
    if (num % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  const int max = 10000;
  int i, size, A[max], count = 0;
  cin >> size;
  for (i = 0; i < size; ++i) {
    cin >> A[i];
    if (isPrime(A[i]))
      ++count;
  }
  cout << count << endl;
  return 0;
}

#include <cmath>
#include <iostream>
using namespace std;

int isPrime(int num) {
  int i;
  if (num <= 1)
    return 0;

  else if (num == 2)
    return 1;
  if (num % 2 == 0)
    return 0;
  for (i = 3; i <= sqrt(static_cast<double>(num)); i += 2) {
    if (num % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  const int max = 10000;
  int i, size, A[max], count = 0;
  cin >> size;
  for (i = 0; i < size; ++i) {
    cin >> A[i];
    if (isPrime(A[i]))
      ++count;
  }
  cout << count << endl;
  return 0;
}


#include <bits/stdc++.h>

bool isprime[100000000];

int main(void) {

  for (int i = 0; i < 100000000; ++i) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;

  for (int i = 2; i < 10000; ++i) {
    if (isprime[i]) {
      for (int j = i + i; j < 100000000; j += i) {
        isprime[j] = false;
      }
    }
  }

  int N;
  int A;
  int ans = 0;

  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> A;
    if (isprime[A]) {
      ans += 1;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

#include <bits/stdc++.h>

bool isprime[10000];

int main(void) {

  for (int i = 0; i < 10000; ++i) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;

  for (int i = 2; i < 100; ++i) {
    if (isprime[i]) {
      for (int j = i + i; j < 10000; j += i) {
        isprime[j] = false;
      }
    }
  }

  int N;
  int A;
  int ans = 0;

  std::cin >> N;
  ans = N;
  for (int i = 0; i < N; ++i) {
    std::cin >> A;
    int n = std::min(10000, A);
    for (int j = 2; j < n; ++j) {
      if (isprime[j]) {
        if (A % j == 0) {
          ans -= 1;
          break;
        }
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


#include <bits/stdc++.h>

int main() {

  const int max = 100000100;

  bool *p;
  p = new bool[max];

  for (int i = 0; i < max; ++i) {
    p[i] = true;
  }

  p[0] = p[1] = false;
  for (int i = 2; i < max; ++i) {
    if (p[i]) {
      for (int j = i * 2; j < max; j += i) {
        p[j] = false;
      }
    }
  }

  int N;
  int temp;
  int ans = 0;
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::cin >> temp;
    if (p[temp]) {
      ans += 1;
    }
  }

  std::cout << ans << std::endl;

  delete[] p;

  return 0;
}

#include <bits/stdc++.h>

int main() {

  const int max = 100000;

  bool *p;
  p = new bool[max];

  for (int i = 0; i < max; ++i) {
    p[i] = true;
  }

  p[0] = p[1] = false;
  for (int i = 2; i < max; ++i) {
    if (p[i]) {
      for (int j = i * 2; j < max; j += i) {
        p[j] = false;
      }
    }
  }

  std::vector<int> pv;
  for (int i = 0; i < max; ++i) {
    if (p[i]) {
      pv.push_back(i);
    }
  }

  int N;
  int temp;
  int ans = 0;
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::cin >> temp;
    for (int j = 0; j < pv.size(); ++j) {
      if (temp % pv[j] == 0 && pv[j] != temp) {
        goto label_1;
      }
    }
    ans += 1;
  label_1:;
  }

  std::cout << ans << std::endl;

  delete[] p;

  return 0;
}


#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <stdlib.h>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;

std::vector<bool> isNotPrime(int max) {
  std::vector<bool> is_not_prime(max + 1);
  for (int i = 2; i <= max / 2; i++) {
    int j = i * 2;
    while (j <= max) {
      is_not_prime[j] = true;
      j += i;
    }
  }
  return is_not_prime;
}

int main(int argc, char *argv[]) {
  int n, max = 0, cnt = 0, num;
  cin >> n;
  std::vector<int> a(n);
  std::vector<bool> is_not_prime;
  for (int i = 0; i < n; i++) {
    cin >> num;
    a[i] = num;
    if (num > max) {
      max = num;
    }
  }
  // cout << "max number is = " << max << endl;
  // maxまでの範囲でエラトステネスの篩
  is_not_prime = isNotPrime(max);

  for (int i = 0; i < n; i++) {
    if (is_not_prime[a[i]] == false) { // 見つかったら
      cnt++;
      // cout << a[i];
      // cout << "は素数" << endl;
    }
  }

  cout << cnt << endl;
  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <stdlib.h>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;

// std::vector<bool> isNotPrime(int max){
//   std::vector<bool> is_not_prime(max+1);
//   for(int i=2; i<=max/2; i++){
//     int j = i*2;
//     while(j <= max){
//       is_not_prime[j] = true;
//       j+=i;
//     }
//   }
//   return is_not_prime;
// }

bool isPrime(int target) {
  // cout << "c" << endl;

  for (int i = 2; i * i <= target; i++) {
    // cout << i << endl;
    if (target % i == 0) {
      // cout << "divide" << endl;
      return false;
    }
  }
  // cout << "d" << endl;

  return true;
}

int main(int argc, char *argv[]) {
  int n, cnt = 0, num;
  cin >> n;
  // std::vector<int> a(n);
  // std::vector<bool> is_not_prime;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (isPrime(num) == true) {
      cnt++;
    }
    // cout << "b" << endl;
  }

  cout << cnt << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  int p, prime = 0;
  int cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> p;
    if (p == 0 || p == 1)
      break;
    cnt = 0;

    for (int j = 2; j <= p; j++) {
      if (p % j == 0)
        cnt++;
    }
    if (cnt == 1)
      prime++;
  }
  cout << prime << endl;
}

#include <bits/stdc++.h>
using namespace std;

bool isprime(int x) {
  if (x == 2)
    return true;

  if (x < 2 || x % 2 == 0)
    return false;

  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int main() {
  int n, x;
  int cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> x;
    if (isprime(x))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, kazu = 0, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 2 || a % 2 == 1) {
      for (int j = 2; j < a; j++) {
        if (a % j == 0) {
          kazu++;
          break;
        }
      }
      if (kazu == 0)
        ans++;
      else
        kazu = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, a, i;
int sub(int x) {
  if (x == 2)
    return true;
  if (x < 2 || x % 2 == 0)
    return false;
  i = 3;
  while (i <= sqrt(x)) {
    if (x % i == 0)
      return false;
    i = i + 2;
  }
  return true;
}
int main() {
  cin >> n;
  for (int j = 0; j < n; j++) {
    cin >> a;
    ans += sub(a);
  }
  cout << ans << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define REP(i, j, n) for (int i = j; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())

using namespace std;

int main() {
  int n, m, count = 0, allcount = 0;
  cin >> n;
  REP(i, 0, n) {
    cin >> m;
    REP(j, 1, m / 2 + 1) {
      if (m % j == 0)
        count++;
      if (count > 1)
        break;
    }
    if (count < 2)
      allcount++;
    count = 0;
  }
  cout << allcount << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define REP(i, j, n) for (int i = j; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())

using namespace std;

bool isPrime(int x) {
  if (x < 2)
    return false;
  if (x == 2 || x == 3)
    return true;
  if (x % 2 == 0)
    return false;

  for (int j = 3; j * j <= x; j += 2) {
    if (x % j == 0)
      return false;
  }
  return true;
}

int main() {
  int n, m, count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    if (isPrime(m))
      count++;
  }

  cout << count << endl;
  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a;
  int c = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    bool f = true;
    for (int t = 2; t < a; t++) {
      if (a / t * t == a) {
        f = false;
        break;
      }
    }
    if (f) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a;
  int c = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    bool f = true;
    int t = 2;
    int s;
    s = a / t;
    for (t = 2; t <= s; t++) {
      if (a / t * t == a) {
        f = false;
        break;
      }
      s = a / t;
    }
    if (f) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


#include <iostream>

using namespace std;

bool is_prime(int n) {
  for (int i = 2; i < n - 1; i++) {
    if ((n % i) == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;

  int count;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    if (is_prime(x)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

#include <bitset>
#include <cmath>
#include <iostream>

using namespace std;

const int N = 100000000 + 1;
bitset<N> arr;

void eratosthenes() {
  for (int i = 2; i < N; ++i) {
    arr[i] = 1;
  }

  for (int i = 2; i < sqrt(N); ++i) {
    if (arr[i]) {
      for (int j = 2; i * j < N; ++j) {
        arr[i * j] = 0;
      }
    }
  }
}

bool is_prime(int n) { return arr[n]; }

int main() {
  eratosthenes();

  int n;
  cin >> n;

  int count;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    if (is_prime(x)) {
      // cerr << "debug: " <<  x << endl;
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define N 100000001

int table[N];

void prim() {
  table[0] = table[1] = 1;
  for (int i = 2; i * i < N; i++) {
    for (int j = 2 * i; j < N; j += i) {
      table[j] = 1;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  prim();
  int n;
  cin >> n;
  int cou = 0, a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (!table[a])
      cou++;
  }
  cout << cou << endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define N 100000001

int table[N];

void prim() {
  table[0] = table[1] = 1;
  for (int i = 2; i * i < N; i++) {
    for (int j = 2 * i; j < N; j += i) {
      table[j] = 1;
    }
  }
}

bool chepri(int n) {
  if (n < 2)
    return false;
  if (n == 2)
    return true;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int cou = 0, a;
  //    prim();
  //    for(int i=0;i<n;i++){
  //        cin >> a;
  //        if(!table[a])cou++;
  //    }
  //    cout << cou << endl;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (chepri(a))
      cou++;
  }
  cout << cou << endl;
}


#include <iostream>
#include <vector>

using namespace std;

typedef unsigned int uint32;

namespace {
bool IsPrime(uint32 x) {
  for (size_t i = 2; i < x; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
} // namespace

int main() {
  uint32 n;
  cin >> n;

  uint32 x;
  uint32 c = 0;
  for (uint32 i = 0; i < n; ++i) {
    cin >> x;
    if (IsPrime(x)) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}

#include <cmath>
#include <iostream>

using namespace std;

typedef unsigned int uint32;

namespace {
bool IsPrime(uint32 x) {
  if (x == 2) {
    return true;
  }
  if (x % 2 == 0) {
    return false;
  }

  const uint32 m = static_cast<uint32>(sqrt(x));
  for (size_t i = 3; i <= m; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
} // namespace

int main() {
  uint32 n;
  cin >> n;

  uint32 c = 0;
  uint32 x;
  for (uint32 i = 0; i < n; ++i) {
    cin >> x;
    if (IsPrime(x)) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}


#include <iostream>

using namespace std;

#define CALC_PRIME_MAX 10000   // _/10 ^ 8
#define PRIME_ELEMENT_MAX 1229 // prime( _/10 ^ 8 )

int prime_number[PRIME_ELEMENT_MAX];

bool isPrime(int element) {
  for (int i = 0; prime_number[i] * prime_number[i] <= element; i++) {
    if (element % prime_number[i] == 0)
      return false;
  }
  return true;
}

void calcPrime() {
  // add 2, 3 (prime)
  int prime_index = 2;
  prime_number[0] = 2;
  prime_number[1] = 3;
  // next prime is 5
  for (int element = 5; element <= CALC_PRIME_MAX; element += 2) {
    bool is_prime = true;
    // judge prime
    for (int i = 1; prime_number[i] * prime_number[i] <= element; i++) {
      if (element % prime_number[i] == 0) {
        is_prime = false;
        break;
      }
    }
    // add prime
    if (is_prime)
      prime_number[prime_index++] = element;
  }
  //	cout << "prime_element_num = " << prime_index << endl;
  return;
}

int main() {
  int n, element, count = 0;
  calcPrime();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> element;
    if (isPrime(element))
      count++;
  }
  cout << count << endl;
  return 0;
}

#include <iostream>

using namespace std;

#define CALC_PRIME_MAX 10007   // _/10 ^ 8 + next prime
#define PRIME_ELEMENT_MAX 1230 // prime( _/10 ^ 8 ) + 1(10007)

int prime_number[PRIME_ELEMENT_MAX];

bool isPrime(int element) {
  for (int i = 0; prime_number[i] * prime_number[i] <= element; i++) {
    if (element % prime_number[i] == 0)
      return false;
  }
  return true;
}

void calcPrime() {
  // add 2, 3 (prime)
  int prime_index = 2;
  prime_number[0] = 2;
  prime_number[1] = 3;
  // next prime is 5
  for (int element = 5; element <= CALC_PRIME_MAX; element += 2) {
    bool is_prime = true;
    // judge prime
    for (int i = 1; prime_number[i] * prime_number[i] <= element; i++) {
      if (element % prime_number[i] == 0) {
        is_prime = false;
        break;
      }
    }
    // add prime
    if (is_prime)
      prime_number[prime_index++] = element;
  }
  //	cout << "prime_element_num = " << prime_index << endl;
  return;
}

int main() {
  int n, element, count = 0;
  calcPrime();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> element;
    if (isPrime(element))
      count++;
  }
  cout << count << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, a, i, tmp;
  int cnt = 0;

  cin >> n;

  while (cin >> a) {
    tmp = 0;
    for (i = 2; i < a; i++) {
      if ((a % i) == 0)
        tmp++;
    }
    if (tmp == 0)
      cnt++;
  }

  cout << cnt << endl;
}

#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n, a, i, tmp;
  int cnt = 0;

  cin >> n;

  while (cin >> a) {
    if (a % 2 != 0) {
      tmp = 0;
      for (i = 2; i <= sqrt(a); i++) {
        if ((a % i) == 0)
          tmp++;
      }
      if (tmp == 0)
        cnt++;
    } else if (a == 2)
      cnt++;
  }

  cout << cnt << endl;
}


#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int n, m;
  int max = 2;
  vector<int> vec;
  vector<int> vecin;
  vector<int>::iterator it;
  int count = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    vecin.push_back(m);
    if (max < m) {
      max = m;
    }
  }

  vec.push_back(2);
  vec.push_back(3);
  vec.push_back(5);
  vec.push_back(7);
  vec.push_back(11);
  vec.push_back(13);
  for (int i = 15; i <= max; i += 2) {
    if (i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0 || i % 13 == 0) {
      continue;
    }
    vec.push_back(i);
  }
  if (max % 2 == 1) {
    vec.push_back(max);
  }

  for (vector<int>::iterator iter = vec.begin(); iter != vec.end(); ++iter) {
    it = iter;
    ++it;
    while (it != vec.end()) {
      if ((*it) % (*iter) == 0) {
        it = vec.erase(it);
      } else {
        ++it;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (vector<int>::iterator iter = vec.begin(); iter != vec.end(); ++iter) {
      if (vecin[i] == (*iter)) {
        count++;
        break;
      }
      if (vecin[i] < (*iter)) {
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

bool check(int a) {
  bool flag = true;

  if (a % 2 == 0) {
    return false;
  }

  for (int i = 3; i <= (int)sqrt(a); i += 2) {
    if (a % i == 0) {
      flag = false;
      break;
    }
  }

  if (flag == true) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int n, m;
  int count = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    if (m == 2) {
      count++;
      continue;
    }
    if (check(m) == true) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


#include <cmath>
#include <iostream>

using namespace std;

void PrimeNumSum(int &sum, unsigned int &num) {
  unsigned int divisor = num / 2 + 1;

  if (divisor == 2) {
    sum++;
    return;
  }
  while (divisor >= 2) {
    if (num % divisor == 0) {
      return;
    }
    divisor--;
  }

  sum++;
}

int main() {
  int count;
  cin >> count;

  unsigned int *list = new unsigned int[count];

  for (int i = 0; i < count; i++) {
    cin >> list[i];
  }

  int sum = 0;

  for (int i = 0; i < count; i++) {
    PrimeNumSum(sum, list[i]);
  }

  cout << sum << endl;

  delete[] list;
  return 0;
}

#include <cmath>
#include <iostream>

using namespace std;

void PrimeNumSum(int &sum, unsigned int &num) {
  unsigned int divisor = sqrt(num) + 1;

  if (divisor == 2) {
    sum++;
    return;
  }
  while (divisor >= 2) {
    if (num % divisor == 0) {
      return;
    }
    divisor--;
  }

  sum++;
}

int main() {
  int count;
  cin >> count;

  unsigned int *list = new unsigned int[count];

  for (int i = 0; i < count; i++) {
    cin >> list[i];
  }

  int sum = 0;

  for (int i = 0; i < count; i++) {
    PrimeNumSum(sum, list[i]);
  }

  cout << sum << endl;

  delete[] list;
  return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;

  int cnt = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    cin >> num;
    for (int j = 1; j < num; j++) {
      if (j == 1) {
        continue;
      }
      if (num % j == 0) {
        num = 0;
        break;
      }
    }
    if (num != 0) {
      cnt += 1;
    }
  }

  cout << cnt << endl;

  return 0;
}

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;

  int cnt = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    cin >> num;
    if (num == 2) {
      cnt += 1;
      continue;
    }
    if (num % 2 == 0) {
      continue;
    }

    double sqrtnum = sqrt(num);
    for (int j = 3; j <= sqrtnum; j += 2) {
      if (num % j == 0) {
        num = 0;
        break;
      }
    }
    if (num != 0) {
      cnt += 1;
    }
  }

  cout << cnt << endl;

  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename t1, class t2> void input(t1 count, t2 array) {
  for (t1 i = 0; i < count; i++) {
    cin >> array[i];
  }
}

template <typename t1, class t2> void output(t1 count, t2 array) {
  for (t1 i = 0; i < count; i++) {
    cout << array[i];
    if (i != count - 1)
      cout << " ";
  }
  cout << endl;
}

ll gcd(ll a, ll b) {
  int x = min(a, b), y = max(a, b);
  if (x == 0)
    return y;
  else
    return gcd(x, y % x);
}

bool prime(int x) {
  for (int i = 2; i < x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main(void) {
  int n, t, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (prime(t))
      c++;
  }
  cout << c << endl;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename t1, class t2> void input(t1 count, t2 array) {
  for (t1 i = 0; i < count; i++) {
    cin >> array[i];
  }
}

template <typename t1, class t2> void output(t1 count, t2 array) {
  for (t1 i = 0; i < count; i++) {
    cout << array[i];
    if (i != count - 1)
      cout << " ";
  }
  cout << endl;
}

ll gcd(ll a, ll b) {
  int x = min(a, b), y = max(a, b);
  if (x == 0)
    return y;
  else
    return gcd(x, y % x);
}

set<ll> prime;

bool isPrime(ll x) {
  for (auto e : prime) {
    if (e >= x)
      return true;
    if (x % e == 0)
      return false;
  }
  return true;
}

int main(void) {
  bool flag;
  for (int i = 2; i <= 100000; i++) {
    flag = true;
    for (auto e : prime) {
      if (i % e == 0) {
        flag = false;
        break;
      }
    }
    if (flag)
      prime.insert(i);
  }
  int n, t, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (isPrime(t))
      c++;
  }
  cout << c << endl;
}


#include <iostream>

using namespace std;

bool isPrime(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int array[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }

  int count = 0;

  for (int i = 0; i < n; i++) {
    if (isPrime(array[i])) {
      count++;
    }
  }
  cout << count << "\\n";
}

#include <cmath>
#include <iostream>

using namespace std;

bool isPrime(int n) {
  int last = sqrt(n);
  for (int i = 2; i <= last; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int array[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }

  int count = 0;

  for (int i = 0; i < n; i++) {
    if (isPrime(array[i])) {
      count++;
    }
  }
  cout << count << "\\n";
}


#include <iostream>

#define MAX 100000001

bool *isPrime = new bool[MAX];

void init() {
  for (int i = 2; i < MAX; i++)
    isPrime[i] = true;

  for (int i = 2; i * i < MAX; i++) {
    if (isPrime[i]) {
      for (int j = i * 2; j < MAX; j += i)
        isPrime[j] = false;
    }
  }
}

int main() {

  init();

  int n, cnt = 0;
  std::cin >> n;

  for (int i = 0, a; i < n; i++) {
    std::cin >> a;
    if (isPrime[a])
      cnt++;
  }

  std::cout << cnt << std::endl;

  delete[] isPrime;
  return 0;
}

#include <iostream>

bool isPrime(int n) {
  bool flg = true;

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flg = false;
      break;
    }
  }
  return flg;
}

int main() {

  int n, cnt = 0;
  std::cin >> n;

  for (int i = 0, a; i < n; i++) {
    std::cin >> a;
    if (isPrime(a))
      cnt++;
  }
  std::cout << cnt << std::endl;

  return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
#define MAX 10000

bool isPrime(int prime);

int main() {
  int N, i, j, count = 0, flag, prime;
  // int prime[MAX];
  bool primeFlag;

  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> prime;
    primeFlag = isPrime(prime);
    if (primeFlag == true)
      count++;
  }

  cout << count << endl;

  return 0;
}

//?卒???属???????????蔵??属
bool isPrime(int prime) {
  int i, j;

  // j = sqrt((double)prime);

  if (prime == 2)
    return true;
  if ((prime % 2) == 0)
    return false;

  for (i = 3; i < (prime / 2); i += 2) {
    if ((prime % i) == 0) {
      return false;
    }
  }
  return true;
}

#include <iostream>
#include <math.h>
using namespace std;
#define MAX 10000

bool isPrime(int prime);

int main() {
  int N, i, j, count = 0, flag, prime;
  // int prime[MAX];
  bool primeFlag;

  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> prime;
    primeFlag = isPrime(prime);
    if (primeFlag == true)
      count++;
  }

  cout << count << endl;

  return 0;
}

//?卒???属???????????蔵??属
bool isPrime(int prime) {
  int i;
  double j;

  j = sqrt((double)prime);

  if (prime == ((int)j * (int)j))
    return false;

  if (prime == 2)
    return true;
  if (prime == 3)
    return true;

  if ((prime % 2) == 0)
    return false;
  if ((prime % 3) == 0)
    return false;

  for (i = 3; (double)i < j; i += 2) {
    if ((prime % i) == 0) {
      return false;
    }
  }
  return true;
}


#include <cmath>
#include <cstdio>

using namespace std;

int isPrime(int a) {
  int boundaly = 2;
  if (a == boundaly)
    return true;
  if (a < boundaly)
    return false;
  if (a % 2 == 0)
    return false;

  double sqNum = sqrt(a);
  for (int i = 0; i < sqNum - 1; i += boundaly) {
    if (a % i == 0)
      return false;
  }

  return true;
}

int main() {
  int input;
  int ans = 0;
  while ((scanf("%d", &input)) != EOF) {
    if (isPrime(input))
      ans++;
  }

  printf("%d\\n", ans);
  return 0;
}

#include <cmath>
#include <cstdio>

using namespace std;

int isPrime(int a) {
  int boundaly = 2;
  if (a < boundaly)
    return false;
  if (a == boundaly)
    return true;
  if (a % 2 == 0)
    return false;

  double sqNum = sqrt(a);
  for (int i = 3; i <= sqNum; i += boundaly) {
    if (a % i == 0)
      return false;
  }

  return true;
}

int main() {
  int n, input;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &input);
    if (isPrime(input))
      ans++;
  }

  printf("%d\\n", ans);
  return 0;
}


#include <iostream>

int gcd(long unsigned int a, long unsigned int b) {
  // assuming a > b
  if (a % b == 0)
    return b;

  return gcd(b, a % b);
}

bool is_prime(long unsigned int n) {
  for (long unsigned int i = 2; i < n; i++)
    if (gcd(n, i) != 1)
      return false;
  return true;
}

bool is_prime_E(long unsigned int n) { return true; }

int main() {

  {
    using namespace std;

    long unsigned int n;
    cin >> n;

    int c = 0;
    for (long unsigned int i = 0; i < n; i++) {
      long unsigned int a;
      cin >> a;
      if (is_prime(a))
        c++;
    }
    cout << c << endl;
  }

  return 0;
}

#include <cmath>
#include <iostream>

int gcd(long unsigned int a, long unsigned int b) {
  // assuming a > b
  if (a % b == 0)
    return b;

  return gcd(b, a % b);
}

bool is_prime(long unsigned int n) {
  for (long unsigned int i = 2; i < n; i++)
    if (gcd(n, i) != 1)
      return false;
  return true;
}

bool is_prime_A(long unsigned int n) {
  for (long unsigned int i = 2; i <= std::sqrt(n); i++)
    if (gcd(n, i) != 1)
      return false;
  return true;
}

bool is_prime_E(long unsigned int n) { return true; }

int main() {

  {
    using namespace std;

    long unsigned int n;
    cin >> n;

    int c = 0;
    for (long unsigned int i = 0; i < n; i++) {
      long unsigned int a;
      cin >> a;
      if (is_prime_A(a))
        c++;
    }
    cout << c << endl;
  }

  return 0;
}