stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):


#include<iostream>

#include<stdio.h>

#include<algorithm>

#include<stack>

#include<cstring>

using namespace std;

typedef long long ll;

ll a[1111111];

int main()

{

	ios::sync_with_stdio(false);

	ll n;	cin>>n;

	ll xx=0;

	ll yy=0;

	ll zz=0;

	ll sum=0;

	string ss[111111];

	

	for(ll i=0;i<n;i++)

	{

		string s;	cin>>s;

		if(s[0]=='B'&&s[s.size()-1]=='A')

		{

//			ss[zz][0]='B';

//			ss[zz][1]='A';

			zz++;

		}

		if(s[0]=='B'&&s[s.size()-1]!='A')

			xx++;	

		if(s[0]!='B'&&s[s.size()-1]=='A')

			yy++;

		for(ll j=0;j<s.size()-1;j++)

		{

			if(s[j]=='A'&&s[j+1]=='B')

				sum++;

		}

		

	}

	//cout<<sum;

	int xx1=0;

	int yy1=0;

	if(zz)

	{

		sum=sum+zz-1;

		if(xx)

			yy1=1;

		if(yy)

			xx1=1;	

	}

	xx=xx+xx1;

	yy=yy+yy1;

	sum=sum+min(xx,yy);

	cout<<sum<<endl;

	return 0;

}




// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e7+5;



int main(){

	int n,sum=0,a=0,b=0,c=0;

	cin>>n;

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

		string s;

		cin>>s;

		int l=s.size();

		if(s[0]=='B') b++;

		if(s[l-1]=='A') a++;

		if(s[0]=='B'&&s[l-1]=='A') c++;

		for(int j=1;j<l;j++){

			if(s[j-1]=='A'&&s[j]=='B') sum++;

			//cout<<sum<<" "<<b<<" "<<a<<endl;

		}

	}

	if(b==c&&a==c&&c!=0) sum--;

	cout<<sum+min(a,b)<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>



using namespace std;



int main(){

	int N;

	cin>>N;

	string s[12345];

	int a[4]={0};

	int ans=0;

	for(int i=0;i<N;i++){

		cin>>s[i];

		int l=s[i].size();

		for(int j=1;j<l;j++){

			if(s[i][j-1]=='A'&&s[i][j]=='B'){

				ans++;

			}	

		}

		if(s[i][0]=='B'){

				a[0]++;

			}

			if(s[i][l-1]=='A'){

				a[1]++;

			}

			if(s[i][l-1]=='A'&&s[i][0]=='B'){

				a[2]++;

			}

	}

//	cout<<ans<<"  "<<a[0]<<"  "<<a[1]<<"  "<<a[2]<<endl;

	if(a[0]<a[1]){

		ans+=a[0];

	}

	else ans+=a[1];

	if(a[0]==a[1]&&a[0]==a[2]&&a[0]!=0) ans--;

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e7+5;



int main(){

	int n,sum=0,a=0,b=0,c=0;

	cin>>n;

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

		string s;

		cin>>s;

		int l=s.size();

		if(s[0]=='B') b++;

		if(s[l-1]=='A') a++;

		if(s[0]=='B'&&s[l-1]=='A') c++;

		for(int j=1;j<l;j++){

			if(s[j-1]=='A'&&s[j]=='B') sum++;

			//cout<<sum<<" "<<b<<" "<<a<<endl;

		}

	}

	if(b==c&&a==c&&c!=0) sum--;

	cout<<sum+min(a,b)<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int maxn = 11000;



string str[maxn];

string s;

char tmp[maxn];

bool vis[maxn];



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int n; cin >> n;

	int ans = 0;

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

		cin >> s;

		int l = 0;

		for(int i = s.length() - 1; i >= 0; -- i) {

			if(i && s[i] == 'B' && s[i - 1] == 'A') {

				++ ans;

				-- i;

			}

			else tmp[l ++] = s[i];

		}

		tmp[l] = 0;

		reverse(tmp, tmp + l);

		str[i] = tmp;

	}

	int ac = 0, bc = 0, cnt = 0;

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

		if(str[i].length()) {

			bool flag = true;

			if(str[i][0] == 'B') ++ bc;

			else flag = false;

			if(str[i][str[i].length() - 1] == 'A') ++ ac;

			else flag = false;

			if(flag) ++ cnt;

		}

	}

	if(ac != bc) ans += min(ac, bc);

	else if(ac){

		if(cnt == ac) ans += ac - 1;

		else ans += ac;

	}

	cout << ans;

	return 0;

}

/*

4

A

BABA

B

AB

*/


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e7+5;



int main(){

	int n,sum=0,a=0,b=0,c=0;

	cin>>n;

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

		string s;

		cin>>s;

		int l=s.size();

		if(s[0]=='B') b++;

		if(s[l-1]=='A') a++;

		if(s[0]=='B'&&s[l-1]=='A') c++;

		for(int j=1;j<l;j++){

			if(s[j-1]=='A'&&s[j]=='B') sum++;

			//cout<<sum<<" "<<b<<" "<<a<<endl;

		}

	}

	if(b==c&&a==c&&c!=0) sum--;

	cout<<sum+min(a,b)<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;

const int maxn = 1e5+10;

int main()

{

	int n;

	cin >> n;

	string s[maxn];

	int cnt = 0;

	int x = 0,y = 0, z = 0; 

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

		cin >> s[i];

		int l =s[i].size();

		for(int j = 1;j < l;j ++){

			if(s[i][j - 1] =='A' && s[i][j] == 'B'){

				cnt ++;

			}

		}

		if(s[i][0] == 'B') x ++;

		if(s[i][l-1] == 'A') y++;

		if(s[i][l-1] == 'A' && s[i][0] =='B') z ++;

	}

	if(x < y)  cnt += x;

	else cnt += y;

	if(x == y && y == z && z != 0) cnt --;

	cout << cnt << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e7+5;



int main(){

	int n,sum=0,a=0,b=0,c=0;

	cin>>n;

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

		string s;

		cin>>s;

		int l=s.size();

		if(s[0]=='B') b++;

		if(s[l-1]=='A') a++;

		if(s[0]=='B'&&s[l-1]=='A') c++;

		for(int j=1;j<l;j++){

			if(s[j-1]=='A'&&s[j]=='B') sum++;

			//cout<<sum<<" "<<b<<" "<<a<<endl;

		}

	}

	if(b==c&&a==c&&c!=0) sum--;

	cout<<sum+min(a,b)<<endl;

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<queue>

#include<vector>

using namespace std;

struct node

{

    long long v,tag;

}tree[1000000*4+1];

void build(int node,int l,int r)

{

    if(l==r)

    {

        tree[node].v=l;

        return;

    }

    build(node*2,l,(l+r)/2);

    build(node*2+1,(l+r)/2+1,r);

    tree[node].v=max(tree[node*2].v,tree[node*2+1].v);

}

void pushdown(int node,int l,int r)

{

    if(tree[node].tag)

    {

        tree[node*2].v+=tree[node].tag;

        tree[node*2+1].v+=tree[node].tag;

        tree[node*2].tag+=tree[node].tag;

        tree[node*2+1].tag+=tree[node].tag;

        tree[node].tag=0;

    }

}

long long query(int node,int st,int ed,int l,int r)

{

    if(st>r||ed<l)

        return -1;

    if(st>=l&&ed<=r)

        return tree[node].v;

    pushdown(node,st,ed);

    return max(query(node*2,st,(st+ed)/2,l,r),query(node*2+1,(st+ed)/2+1,ed,l,r));

}

void update(int node,int st,int ed,int l,int r,int ind)

{

    if(st>r||ed<l)

        return;

    if(st>=l&&ed<=r)

    {

        tree[node].v+=ind;

        tree[node].tag+=ind;

        return;

    }

    pushdown(node,st,ed);

    update(node*2,st,(st+ed)/2,l,r,ind);

    update(node*2+1,(st+ed)/2+1,ed,l,r,ind);

    tree[node].v=max(tree[node*2].v,tree[node*2+1].v);

}

vector<int> p[200001];

int main()

{

    long long n,m; 

    cin>>n>>m;

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

	{

		int l,r;

		scanf("%d%d",&l,&r);

		p[l].push_back(r);

    }

	long long ans=n-m;

    build(1,1,m+1);

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

	{

		for(int j=0;j<p[i].size();j++)

		{

			int right=p[i][j];

			update(1,1,m+1,1,right,1);

		}

		ans=max(ans,query(1,1,m+1,i+1,m+1)-m-i-1);

	}

	printf("%lld",ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#include <queue>

using namespace std;

const int N=200005;

int n,m;

struct People{

    int l,r,id;

    friend bool operator < (People a,People b){

        return a.r>b.r;

    }

}a[N],b[N];

bool inq[N];

int cnt;

priority_queue<People> q;

bool cmpl(const People &a,const People &b){

    return a.l<b.l;

}

bool cmpr(const People &a,const People &b){

    return a.r>b.r;

}

int main(){

    scanf("%d%d",&n,&m);

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

        scanf("%d%d",&a[i].l,&a[i].r);

    sort(a+1,a+1+n,cmpl);

    int nowl=0,nowr=m+1,last;

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

        a[i].id=i;

        if(nowl+1<=a[i].l){

            nowl++;

            q.push(a[i]);

            inq[i]=true;

        }

        else if(!q.empty()){

            People best=q.top();

            if(a[i].r>best.r){

                q.pop();

                inq[best.id]=false;

                q.push(a[i]);

                inq[i]=true;

            }

        }

    }

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

        if(!inq[i])

            b[++cnt]=a[i];

    sort(b+1,b+1+cnt,cmpr);

    for(int i=1;i<=cnt&&nowr-1!=nowl;i++)

        if(nowr-1>=b[i].r)

            nowr--;

    printf("%d\n",n-(nowl+(m-nowr+1)));

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



typedef tuple< int, int, int > Pi;



int N, M, L[200000], R[200000];

int ans = 11451419;

Pi first[200000], second[200000];



int check(int vq)

{

  vector< Pi > que2;

  int tail = 1;

  bool used[200000] = {};

  for(int i = 0; i < N; i++) {

    int l, r, idx;

    tie(l, r, idx) = first[i];

    if(tail <= l && tail < vq) {

      tail++;

      used[idx] = true;

    }

  }

  int head = M;

  int ret = 0;

  for(int i = 0; i < N; i++) {

    int l, r, idx;

    tie(r, l, idx) = second[i];

    if(used[idx]) continue;

    r *= -1;

    if(r <= head && head >= tail) {

      head--;

    } else {

      ++ret;

    }

  }

  ans = min(ans, ret);

  return (ret);

}



int main()

{

  cin >> N >> M;

  for(int i = 0; i < N; i++) cin >> L[i] >> R[i];

  for(int i = 0; i < N; i++) first[i] = make_tuple(L[i], -R[i], i);

  for(int i = 0; i < N; i++) second[i] = make_tuple(-R[i], L[i], i);

  sort(second, second + N);

  sort(first, first + N);





  int low = 1, high = M + 1;

  while(high - low > 1) {

    int mid = (low + high) >> 1;

    (check(mid) - check(mid - 1) > 0 ? low : high) = mid;

  }

  check(0);

  check(M + 1);

  for(int i = low - 30; i <= high + 30; i++)check(i);





  cout << ans << endl;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

 

using namespace std;

 

typedef tuple< int, int, int > Pi;

 

int N, M, L[200000], R[200000];

int ans = 11451419;

Pi first[200000], second[200000];

 

int check(int vq)

{

  vector< Pi > que2;

  int tail = 1;

  bool used[200000] = {};

  for(int i = 0; i < N; i++) {

    int l, r, idx;

    tie(l, r, idx) = first[i];

    if(tail <= l && tail < vq) {

      tail++;

      used[idx] = true;

    }

  }

  int head = M;

  int ret = 0;

  for(int i = 0; i < N; i++) {

    int l, r, idx;

    tie(r, l, idx) = second[i];

    if(used[idx]) continue;

    r *= -1;

    if(r <= head && head >= tail) {

      head--;

    } else {

      ++ret;

    }

  }

  ans = min(ans, ret);

  return (ret);

}

 

int main()

{

  cin >> N >> M;

  for(int i = 0; i < N; i++) cin >> L[i] >> R[i];

  for(int i = 0; i < N; i++) first[i] = make_tuple(L[i], -R[i], i);

  for(int i = 0; i < N; i++) second[i] = make_tuple(-R[i], L[i], i);

  sort(second, second + N);

  sort(first, first + N);

 

  int low = 1, high = M + 1;

  while(high - low > 1) {

    int mid = (low + high) >> 1;

    (check(mid) - check(mid - 1) > 0 ? low : high) = mid;

  }

  check(0);

  check(M + 1);

  cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long gcd(long long a, long long b);

int main(){

    long long a,b;

    cin>>a>>b;

    long long n=gcd(a,b);

    //cout<<n<<endl;

    vector<int> prime(1000001,0);

    int ans=1;

    for(long long i=2;i*i<=n;i++){

        //cout<<i<<" "<<n<<endl;

        if(n%i==0){

            while(n%i==0){

                n/=i;

            }

            ans++;

        }

    }

    if(n!=1)ans++;

    cout<<ans<<endl;

    return 0;

}



long long gcd(long long a,long long b){

    if(b==0)return a;

    else return gcd(b,a%b);

}

// Optimized solution to the same problem (faster):
#include<iostream>

using namespace std;

long long gcd(long long a, long long b);

int main(){

    long long a,b;

    cin>>a>>b;

    long long n = gcd(a,b);

    int ans=1;

    for(long long i=2;i*i<=n;i++){

        if(n%i==0){

            while(n%i==0){

                 n/=i;

            }

            ans++;

        }

    }

    if(n!=1)ans++;

    cout<<ans<<endl;

    return 0;

}

long long gcd(long long a, long long b){

    if(b==0)return a;

    else return gcd(b,a%b);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma warning(disable:4996)

#include<iostream>

#include<cstdio>

#include<cmath>

#include<string>

using namespace std;



const int maxn1 = 60;

int fac[maxn1 + 10], cnt[maxn1 + 10];

long long getFac(long long n)

{

	long long num = 0, sum = 0, m = sqrt(n + 0.5);

	for (long long k = 2; k <= m; k++)

	{

		sum = 0;

		while (n % k == 0)

		{

			n /= k;

			sum++;

		}

		if (sum != 0)

		{

			fac[num] = k;

			cnt[num++] = sum;

		}

		m = sqrt(n + 0.5);

	}

	if (n != 1)

	{

		fac[num] = n;

		cnt[num++] = 1;

	}

	return num;

}



long long gcd(long long a, long long b)

{

	return b ? gcd(b, a % b) : a;

}





int main()

{

	long long x, y;

	scanf("%lld%lld", &x, &y);

	printf("%lld\n", getFac(gcd(x, y)) + 1);

	//system("pause");

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

#define ll long long

bool isprime(ll x)

{

    for(ll i=2;i*i<=x;i++)

        if(x%i==0)

            return 0;

    //cout<<x<<endl;

    return 1;

}

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    ll a,b;

    cin>>a>>b;

    ll g=__gcd(a,b);

    ll ans=0;

    for(ll i=2;i*i<=g;i++)

        if(g%i==0)

        {

            ans++;

            while(g%i==0)

                g/=i;

        }

    if(g!=1)ans++;

    cout<<ans+1<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define sz(v)           ((int)((v).size()))

#define clr(v, d)       memset(v, d, sizeof(v))

#define rep(i, v)       for(int i=0; i<sz(v); ++i)

#define lp(i, n)        for(int i=0; i<(int)(n); ++i)

#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)

#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)

#define INF             1000000000



typedef long long ll;

typedef pair<int, int> ii;

typedef vector<ii> vii;

typedef vector<int> vi;



void init(){

	std::ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

}



const int N = 1e6+5;

bool arr[N];



int main()

{

	init();

	ll a, b;

	int ans = 1;

	cin >> a >> b;

	a = __gcd(a, b);

	if(a % 2 == 0){

		++ans;

		while(a % 2 == 0)

			a /= 2;

	}

	b = sqrt(a);

	b = min(1000000LL, b+1);

	for (ll i = 3; i < b; i += 2) {

		if(!arr[i]){

			if(a % i == 0){

				++ans;

				while(a % i == 0)

					a /= i;

			}

			for (ll j = i * i; j < b; j += 2*i) {

		    	arr[j] = 1;

		    }

		}

	}

	if(a > 1)

		++ans;

	cout << ans;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



#define FastRead        ios_base::sync_with_stdio(0);cin.tie(NULL);

#define endl            "\n"

#define NUM             1000005

typedef long long ll;



map<ll,ll>mp;



void primeFactors(ll A)

{

    while(A%2==0)

    {

        mp[2]++;

        A/=2;

    }



    for(ll i=3;i<=sqrt(A);i+=2)

    {

        while(A%i==0)

        {

            mp[i]++;

            A/=i;

        }

    }



    if(A>2)

        mp[A]++;

}



int main()

{

    FastRead



    ll a,b,ans=1;



    cin>>a>>b;



    ll gcd = __gcd(a,b);



    primeFactors(gcd);



    ans+=mp.size();



    cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include<cstdio>

#include<string.h>

#include<cmath>

#include<algorithm>

using namespace std;

#define ll long long

#define INF  0x7fffffffffff//ffff

#define M 112300

ll a[M],ans = 0,n,m;

bool check(ll x){

	if(x==2)

	return true;

	for(ll i = 2;i*i <=x;i++){

		if(x %i==0)

		return false;

	}

	return true;

}

int main(void){

	cin>>n>>m;

	if(n < m)

	swap(n,m);

	ll j = 0;

	for(ll i = 1;i *i <= m;i++){

		if(m %i==0){

			a[j] = i;

			j++;

			if(i*i!=m){

			a[j] = m/i;

			j++;

		}

		}

	}

	for(ll i = 0;i < j;i++){

		if(n % a[i]==0&&check(a[i]))

		ans++;

	}

	

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
        //#include <bits/stdc++.h>

        #include<iostream>

        #include<algorithm>

        #include<set>

        #include<map>

        #include<math.h>

        //#include <ttmath.h>

        #define endl '\n'

        #define modulo 1000000007

        #define int long long

        #pragma GCC optimize("-Ofast")

        #define float double

        #define PI 3.141592653589793238462643

        #define sinDegrees(x) sin((x) * PI / 180.0)

        #define tanDegrees(x) tan((x) * PI / 180.0)

        #define atanDegrees(x) atan(x)* 180.0 / PI

        using namespace std;

        int power(int x,int y)

        {

        int temp;

        if(y == 0)

        return 1;

        temp = (power(x, y/2))%modulo;

        if (y%2 == 0)

        return ((temp%modulo)*temp)%modulo;

        else

        return ((x*temp%modulo)*temp)%modulo;

        }

        int inv(int x)

        {

        return (power(x,modulo-2)+modulo)%modulo;

        }

        /*#include "testlib.h"

        int main(int argc, char* argv[])

        {

        iostream::sync_with_stdio(0);

        cin.tie(0);

        cout.tie(0);

        registerGen(argc, argv, 1);

        int n,k;

        n=rnd.next(1,50);

        k=rnd.next(1,n);

        cout<<n<<' '<<k;

        }*/

        bool comp(pair<int,int>a,pair<int,int> b)

        {

            return a.second>b.second;

        }

        set<int>lol;

        void factorize(int n){

        if(n==1)

        return;

        for(int i=2;i*i<=n;i++){

        if(n%i==0){

        factorize(n/i);

        lol.insert(i);

        return;

        }

        }

        lol.insert(n);

        }

        int32_t main()

        {

            //freopen("output.txt","w", stdout);

            //freopen("input4.txt","r", stdin);

            iostream::sync_with_stdio(0);

            cin.tie(0);

            cout.tie(0);

            int a,b;

            cin>>a>>b;

            int result=(__gcd(a,b));

            factorize(result);

            cout<<lol.size()+1;

            return 0;

        }


// Optimized solution to the same problem (faster):
#include<cstring>

#include<algorithm>

#include<cstdio>

#define N 100005

using namespace std;

long long int a[30],b[30];

long long int x,y;

int la=0,lb=0;

int main(){

scanf("%lld%lld",&x,&y);

a[++la]=1;

b[++lb]=1;

for(long long int i=2;i*i<=x;i++){

if(x%i==0){a[++la]=i;}

while(x%i==0){x/=i;}

}

if(x>1)a[++la]=x;

for(long long int i=2;i*i<=y;i++){

if(y%i==0){b[++lb]=i;}

while(y%i==0){y/=i;}

}

if(y>1)b[++lb]=y;

int z=1;

int ans=0;

for(int i=1;i<=la;i++){

while(b[z]<a[i]&&z<lb)z++;

if(b[z]==a[i])ans++;

}

printf("%d",ans);



}

// Fastest known solution for this problem: