#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_N = 1005;

int c[MAX_N][MAX_N];

int main()
{
	string X,Y;
	cin >> X;
	cin >> Y;
	for(int i=0;i<=X.length();i++){
		c[i][0] = i;
	}
	for(int j=0;j<=Y.length();j++){
		c[0][j] = j;
	}
	for(int i=1;i<=X.length();i++){
		for(int j=1;j<=Y.length();j++){
			int p,q,r;
			if(X[i-1] == Y[j-1]){
				p = c[i-1][j-1];
			}else{
				p = c[i-1][j-1] + 1;
			}
			q = c[i][j-1] + 1;
			r = c[i-1][j] + 1;
			c[i][j] = min(min(p,q),r);
		}
	}
	cout << c[X.length()][Y.length()] << "\n";
}
#include <bits/stdc++.h>
#define max 1000007
#define ll long long int
using namespace std;
vector <ll> primes;
void sieve()
{
    bool isprime[max+1];
    for(ll i=0;i<=max;i++) {
        isprime[i] = true;
    }
    isprime[0]=false;
    isprime[1]=false;
    for(ll i=3;i*i<=(max);i=i+2)
    {
        if(isprime[i]) {
            for (ll j = i*i; j  <= max; j=j+i) {
                isprime[j] = false;
            }
        }
    }
    primes.push_back(2);
    for(ll i=3;i<max;i=i+2)
    {
        if(isprime[i])
            primes.push_back(i);
    }
}
int main() {
    sieve();
    ll n,d,b,i,flag,x;
   scanf("%lld %lld",&d,&b);
    n=__gcd(d%b,b);
    set <int> s;
    s.insert(1);
    for(i=0;primes[i]*primes[i]<=n;i++)
    {
        while(n%primes[i]==0)
        {
            s.insert(primes[i]);
            n=n/primes[i];
        }
    }
    if(n>1)
        s.insert(n);
    printf("%lu",s.size());
    return 0;
}