#include "bits/stdc++.h"
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const int TIMELIMIT = 2850;

class Pair{
    public:
    string s;
    ll score;
};

class Point{
    public:
    int x, y;
    Point(int x = 0, int y = 0):x(x), y(y){};
    Point operator + (const Point p) {
        return Point((x + p.x)%20, (y + p.y)%20);
    }
};

class Board{
    private:
    std::vector<std::vector<char> > m;
    public:
    void init(){
        m = vector<vector<char> >(20, vector<char>(20, '.'));
    }
    void show(){
        rep(y, 20){
            rep(x, 20)cout << m[y][x];
            cout << endl;
        }
    }
    std::vector<char> operator[] (const int i) const {return m[i];};
    std::vector<char>& operator[] (const int i) {return m[i];};
    char operator[] (const Point p) const {return m[p.y][p.x];};
    char& operator[] (const Point p) {return m[p.y][p.x];};

    bool isContain(Point p) const {
        return p.y != 20;
    }

    Point nextPoint(Point p) const {
        p.x++;
        if (p.x == 20) {
            p.x = 0;
            p.y++;
            if (p.y == 20)p.y=0;
        }
        return p;
    }

    Board(){
        init();
    }
};

ll N, M;
vector<string>str;
mt19937 mt;

bool putString(Board &board, const string &s){
    ll sLen = s.size();
    Point bestPoint(20, 20);
    ll bestScore = -1;
    ll bestDir = 0;
    Point rp(mt() % 20, mt() % 20);
    for (Point p = rp; ;) {
        ll widthScore = sLen;
        ll heightScore = sLen;
        rep(i, sLen) {
            Point wIdx(i, 0);
            if (board[p + wIdx] == '.')widthScore--;
            else if (board[p + wIdx] != s[i])widthScore -= 100;

            Point hIdx(0, i);
            if (board[p + hIdx] == '.')heightScore--;
            else if (board[p + hIdx] != s[i])heightScore -= 100;
        }
        if (widthScore >= 0 && widthScore > bestScore) {
            bestPoint = p;
            bestScore = widthScore;
            bestDir = 1;
        }
        if (heightScore >= 0 && heightScore > bestScore) {
            bestPoint = p;
            bestScore = heightScore;
            bestDir = 2;
        }
        p = board.nextPoint(p);
        if (rp.x == p.x && rp.y == p.y)break;
    }
    if (bestDir == 0)return false;
    rep(i, sLen){
        Point idx(i, 0);
        if (bestDir == 2)idx = Point(0, i);
        board[bestPoint + idx] = s[i];
    }
    return true;
}

int main(){
    chrono::system_clock::time_point  start, end;
    start = chrono::system_clock::now(); // 計測開始時間
    random_device rd;
    mt = mt19937(rd());

    cin >> N >> M;
    str = vector<string>(M);
    rep(i, M)cin >> str[i];

    Board board;

    vector<Pair>pairVector(M);
    rep(i, M) {
        pairVector[i].s = str[i];
        ll cnt = 0;
        pairVector[i].score = 0;
        rep(j, M){
            if (str[i].find(str[j]) != string::npos) {
                cnt++;
            }
        }
        pairVector[i].score = cnt * 66528000;
        pairVector[i].score /= str[i].size();
        pairVector[i].score += cnt;
    }
    sort(pairVector.begin(), pairVector.end(), [](auto const& lhs, auto const& rhs) {
        return lhs.score > rhs.score;
    });
    rep(i, M) {
        putString(board, pairVector[i].s);
    }

    board.show();

    return 0;
    for (int step = 0;; step++) {
        end = std::chrono::system_clock::now();  // 計測終了時間
        auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
        if(elapsed > TIMELIMIT)break;

    }

    return 0;
}

// Generated by 2.3.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

#define SUBMIT

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

using Uint = uint64_t;

constexpr int n = 20;
array<Uint, n> h_res, w_res;

void solve(long long m, std::vector<std::string> s){

    // sort(s.begin(), s.end(), [](auto x, auto y){return x.size() < y.size();});
    int min_len = 100;
    int max_len = 0;

    vector<pair<int,Uint>> target(m);
    for(int i = 0; i < m; ++i){
        chmin(min_len, int(s[i].size()));
        chmax(max_len, int(s[i].size()));
        target[i].first = s[i].size();
        target[i].second = 0;
        for(int j = 0; j < s[i].size(); ++j){
            target[i].second |= ((s[i][j] - 'A') << (3 * j));
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            Uint val = (rand() & 7);
            h_res[i] |= val << (j * 3);
            w_res[j] |= val << (i * 3);
        }
    }

    auto get = [&](int i, int j){
        Uint h = (h_res[i] >> (3 * j)) & 7;
        Uint w = (w_res[j] >> (3 * i)) & 7;
        assert(h == w);
        return h;
    };
    auto get_h = [&](int i, int j, int len){
        Uint h = (h_res[i] >> (3 * j)) & ((1uLL << (3 * len)) - 1);
        if(j + len > n){
            int over = j + len - n;
            return h | Uint((h_res[i] & ((1uLL << (3 * over)) - 1)) << (3 * (n - j)));
        }
        return h;
    };
    auto get_w = [&](int i, int j, int len){
        Uint w = (w_res[j] >> (3 * i)) & ((1uLL << (3 * len)) - 1);
        if(i + len > n){
            int over = i + len - n;
            return w | Uint((w_res[j] & ((1uLL << (3 * over)) - 1)) << (3 * (n - i)));
        }
        return w;
    };

    // TODO: hash_map
    vector<unordered_map<Uint, int>> now_hash(max_len + 1);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            for(int l = min_len; l <= max_len; ++l){
                ++now_hash[l][get_h(i, j, l)];
                ++now_hash[l][get_w(i, j, l)];
            }
        }
    }

    // 以下回答関連
#ifndef SUBMIT
    int ans = 0;
    for(int i = 0; i < m; ++i){
        auto t = target[i];
        if(now_hash[t.first].count(t.second)){
            cout << "correct: " << i << "  " << s[i] << endl;
            ++ans;
        }
    }

    cout << "ans: " << ans << endl;
    cout << Uint(round(1e8 * ans / m)) << endl;
#endif

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cout << char('A' + ((h_res[i] >> (3 * j)) & 7));
        }
        cout << endl;
    }

    cout << endl;
}

signed main(){

#ifndef SUBMIT
    long long N;
    long long M;
    ifstream fs("../contests/ahc004/A/in/0001.txt");
    assert(fs.is_open());
    fs >> N >> M;
    std::vector<std::string> s(M);
    for(int i = 0 ; i < M ; i++){
        fs >> s[i];
    }
#else

    long long N;
    std::scanf("%lld", &N);
    long long M;
    std::scanf("%lld", &M);
    std::vector<std::string> s(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> s[i];
    }
#endif
    solve(M, std::move(s));
    return 0;
}


#include<cstdio>
#define max(a,b) ((a)>(b)? (a):(b))
#define min(a,b) ((a)<(b)? (a):(b))
typedef long long ll;
const ll inf=1e8;
int n,m,res=0,cnt=0,tot=0;
int b[300005];
ll f[300005],g[300005];
int h[300005],to[600005],ver[600005];
inline int read() {
	register int x=0,f=1;register char s=getchar();
	while(s>'9'||s<'0') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=x*10+s-'0';s=getchar();}
	return x*f;
}
inline void add(int x,int y) {
	to[++cnt]=y;
	ver[cnt]=h[x];
	h[x]=cnt;
}
void dfs(int x,int fa,int mid)
{
	f[x]=-inf;g[x]=inf;
	for(register int i=h[x];i;i=ver[i])
    {
		int y=to[i];
		if(y==fa) continue;
		dfs(y,x,mid);
		f[x]=max(f[x],f[y]+1);
		g[x]=min(g[x],g[y]+1);
	}
	if(f[x]+g[x]<=mid) f[x]=-inf;
	if(g[x]>mid&&b[x]==1) f[x]=max(f[x],0);
	if(f[x]==mid) f[x]=-inf,g[x]=0,++tot;
}
int check(int x) {
	tot=0;
	dfs(1,-1,x);
	if(f[1]>=0) ++tot;
	return tot<=m;
}
int main() {
	n=read(),m=read();
	for(register int i=1;i<=n;++i) b[i]=1;
	for(register int i=1;i<n;++i) {
		int x=read(),y=read();
		add(x,y);add(y,x);
	}
	int L=0,R=n;
	while(L<=R) {
		int mid=L+R>>1;
		if(check(mid)) {R=mid-1;res=mid;}
		else {L=mid+1;}
	}
	printf("%d\n",res);
	return 0;
}

#include <bits/stdc++.h>

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; for(int tt = 0; tt < t; ++tt)
#define sz(x) (int)(x).size()
#define sort_unique(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()));
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 800 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
/**
Read problem statement carefully
**/
int arr[N][N];

int n, k;
bool check(int mid, int L){
    vector<vector<int>> pre(n+1, vector<int>(n+1));
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            pre[i][j] = pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1] + (arr[i-1][j-1] >= mid);

    bool ok = 1;
    for(int i = 0; i+k <= n; ++i){
        for(int j = 0; j+k <= n; ++j){
            int res = pre[i+k][j+k] - pre[i+k][j] - pre[i][j+k] + pre[i][j];
            if(res < L) ok = 0;
        }
    }
    return ok;
}

void solve(int T){
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> mp;
    for(int i = 0, x, y; i < m; ++i){
        cin >> x >> y;
        mp[x].push_back(y);
    }

    set<int> st;
    st.insert(n);
    for(auto &[x, v]: mp){
        vector<int> add;
        for(auto &y: v){
            if(st.count(y-1) || st.count(y+1))
                add.push_back(y);
        }
        for(auto &y: v) st.erase(y);
        for(auto &y: add) st.insert(y);
    }

    cout << sz(st) << "\n";
}

int main()
{
    Fast;
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // louisfghbvc
        solve(1);
    return 0;
}

/**
Enjoy the problem.
**/


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

const int mod=998244353,maxn=2e5+10;
int T,n,m,k,x,y;
long long a[maxn],b[maxn],c[maxn];

void solve(long long a[], long long b[], long long d[]) {
	memset(c,0,sizeof(c));
	for (int i=1;i<=m;++i) {
		for (int j=i;j<=m;j+=i) {
			c[j] += a[i]*b[j/i];
			c[j] %= mod;
		}
	}
	for (int i=1;i<=m;++i) {
		d[i] = c[i];
	}
}

int main(int argc, char const *argv[]) {
	long long ans=0;
	scanf("%d %d", &n, &m);
	for (int i=1;i<=m;++i) {
		a[i] = 1;
	}
	b[1] = 1;
	while (n) {
		if (n&1) solve(a,b,b);
		solve(a,a,a);
		n >>= 1;
	}
	for (int i=1;i<=m;++i) {
		ans += b[i];
	}
	printf("%lld\n", ans%mod);
	return 0;
}

#include <iostream>

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ff first
#define ss second
#define REP(i,st,en) for (int i = st; i <= en; i++)
#define REPR(i,st,en) for (int i = st; i >= en; i--)

const int MOD = 998244353;

class Modint {
public:
	long long val;

	Modint (long long _val = 0) {
		if (_val >= MOD) _val %= MOD;
		val = _val;
	}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		if (val >= MOD) val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, long long k) {
	Modint res = 1;
	while (k) {
		if (k & 1) res *= a;
		a *= a;
		k >>= 1;
	}
	return res;
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

const int maxn = 2e5;

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (int i = 2; i <= maxn; i++) {
		fact[i] = fact[i - 1] * i;
	}
	inv_fact[maxn] = inv(fact[maxn]);
	for (int i = maxn - 1; i >= 0; i--) inv_fact[i] = inv_fact[i + 1] * (i + 1);
}

Modint C(int n, int r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}

class MainClass {
public:

	void solve() {

		int n, m; cin >> n >> m;

		if (m == 1) {
			cout << 1;
			return;
		}

		int lgm = log2(m) + 1;

		Modint ans = 0;
		vector<Modint> dp(m + 1, 1);

		for (int i = 1; i <= lgm; i++) {
			vector<Modint> new_dp(m + 1, 0);
			Modint curr = 0;

			for (int j = 1; j <= m; j++) {
				for (int k = 2 * j; k <= m; k += j) new_dp[k] += dp[j];
				curr += dp[j];
			}

			ans += C(n - 1, i - 1) * curr;
			dp.swap(new_dp);
		}

		cout << ans;

		return;
	}
};

int main() {
	preC();

	int test = 1; //cin >> test;
	for (int tst = 1; tst <= test; ++tst) {
		MainClass Ausmosian;

		Ausmosian.solve();
		cout << "\n";
	}

	return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int to[400001], ne[400001], he[200001];
int Q[200001], pl[200001], dl[200001];

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

	int N, K;
	cin >> N >> K;
	int k = 1;
	rep(i, N - 1) {
		int u, v;
		cin >> u >> v;
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int q = 0, p = 0;
	Q[q++] = 1;
	while (p < N) {
		int u = Q[p++];
		int tmp = 0;
		int ind = he[u];
		he[u] = 0;
		while (ind) {
			int v = to[ind];
			tmp = ne[ind];
			if (he[v] > 0) {
				Q[q++] = v;
				ne[ind] = he[u];
				he[u] = -ind;
			}
			ind = tmp;
		}
	}

	int are = 1000000, pd0 = are;
	int L = 0, R = (N + K - 1) / K;
	while (L + 1 < R) {
		int wj = (L + R) / 2;

		int num = 0;

		for (int i = N - 1; i >= 0; i--) {
			int po = pd0 - 1;
			int dd = pd0;
			int u = Q[i];
			for (int ind = -he[u]; ind; ind = -ne[ind]) {
				int v = to[ind];
				if (po < pl[v]) po = pl[v];
				if (dd < dl[v]) dd = dl[v];
			}
			if (po >= dd) dd = 0;
			if (dd >= pd0 + wj) {
				num++;
				po = pd0 + wj;
				dd = 0;
			}
			pl[u] = po - 1;
			dl[u] = dd + 1;
		}

		int are = num + (dl[1] > pd0);
		if (are > K) L = wj;
		else R = wj;

		pd0 += are;
	}

	co(R);

	Would you please return 0;
}

#include<bits/stdc++.h>
#define il inline
#define re register
#define ll long long
using namespace std;
#define MAXN 200005
namespace hyy
{
	#define DEBUG 1
	#define isdigit(x) (x>='0'&&x<='9')
    const int MAXSIZE=1<<20;
    inline char gc()
	{
		#if DEBUG
        return getchar();
		#endif
        static char buf[MAXSIZE];
		static char *p1=buf+MAXSIZE;
		static char *p2=buf+MAXSIZE;
        if(p1==p2)
		{
        	p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin);
		}
		if(p1==p2)
		{
			return -1;
		}
		return *p1++;
    }
    inline bool blank(char ch)
	{
        return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
    }
    template<class T> inline void read(T &x)
	{
        register double tmp=1;
        register bool sign=0;
        x=0;
        register char ch=gc();
        for(;!isdigit(ch);ch=gc())
		{
        	if(ch=='-')
			{
        		sign=1;
			}
		}
        for(;isdigit(ch);ch=gc())
		{
        	x=(x<<1)+(x<<3)+(ch^48);
		}
        if(ch=='.')
		{
        	for(ch=gc();isdigit(ch);ch=gc())
			{
        		tmp/=10.0;
				x+=tmp*(ch-48);
			}
		}
        if(sign)
		{
        	x=-x;
		}
    }
    inline void read(char *s)
	{
        register char ch=gc();
        for(;blank(ch);ch=gc());
	    for(;!blank(ch);ch=gc())
		{
    		*s++=ch;
		}
        *s=0;
    }
    inline void read(char &c)
	{
        for(c=gc();blank(c);c=gc());
    }
    inline void push(const char &c)
	{
        char pbuf[MAXSIZE];
		char *pp=pbuf;
        if (pp-pbuf==MAXSIZE)
		{
        	fwrite(pbuf,1,MAXSIZE,stdout);
			pp = pbuf;
		}
        *pp++=c;
    }
    template<class T> inline void write(T x)
	{
        static T sta[35];
        T top=0;
        do
		{
            sta[top++]=x % 10;
			x/=10;
        }
		while(x);
		#if DEBUG
        while(top)
		{
        	putchar(sta[--top]+'0');
		}
        return;
		#endif
        while(top)
		{
        	push(sta[--top]+'0');
		}
    }
    template<class T> inline void write(T x,char lastChar)
	{
        write(x);
		putchar(lastChar);
    }
}
using namespace hyy;
using namespace std;
#define in(num) read(num)
#define out(num) write(num)
//#define mod 998244353
//int n,m;
//ll f[2][MAXN],ans;
//int main(){
//	freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
//	scanf("%d%d",&n,&m);
//	for(re int i=1;i<=m;++i)f[1][i]=1;
//	for(re int i=2,now=0;i<=n;now^=1,++i){
//		for(re int j=1;j<=m;++j){
//			f[now][j]=0;
//			for(re int k=1;k*k<=j;++k){
//				if(!(j%k)){
//					f[now][j]+=f[now^1][k];
//					if(k*k!=j)f[now][j]+=f[now^1][j/k];
//					f[now][j]%=mod;
//				}
//			}
//		}
//	}
//	for(re int i=1;i<=m;++i)ans+=f[n&1][i],ans%=mod;
//	printf("%lld",ans);
//}
#define inf 1e8
int n,m,tot,f[MAXN],g[MAXN];
struct Edge{int next,to;}E[MAXN<<1];
int head[MAXN],cnt;
il void Add(int x,int y){
	E[++cnt].next=head[x],E[cnt].to=y,head[x]=cnt;
}
void dfs(int x,int fa,int mid){
	f[x]=-inf,g[x]=inf;
	for(re int i=head[x];i;i=E[i].next){
		int to=E[i].to;
		if(to==fa)continue;
		dfs(to,x,mid);
		f[x]=max(f[x],f[to]+1),g[x]=min(g[x],g[to]+1);
	}
	if(f[x]+g[x]<=mid)f[x]=-inf;
	if(g[x]>mid)f[x]=max(f[x],0);
	if(f[x]==mid)f[x]=-inf,g[x]=0,++tot;
}
il bool check(int x){
	tot=0,dfs(1,-1,x);
	return tot+(f[1]>=0)<=m;
}
int main(){
	scanf("%d%d",&n,&m);
	for(re int i=1,x,y;i<n;++i)scanf("%d%d",&x,&y),Add(x,y),Add(y,x);
	int l=0,r=n,ans=0;
	for(re int mid;l<=r;mid=l+r>>1,check(mid)?r=(ans=mid)-1:l=mid+1);
	printf("%d\n",ans);
}


#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define F first
#define S second

// template<typename _Ty1, typename _Ty2>
// ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
//     _os << '(' <<_p.first << ',' << _p.second << ')';
//     return _os;
// }
//
// template<typename _Ty1, typename _Ty2>
// istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
//     _is >> _p.first >> _p.second;
//     return _is;
// }

ll gcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll x1, y1;
  ll d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}

bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
  g = gcd(abs(a), abs(b), x0, y0);
  if (c % g) {
    return false;
  }

  x0 *= c / g;
  y0 *= c / g;
  if (a < 0) x0 = -x0;
  if (b < 0) y0 = -y0;
  return true;
}

ll gcd(ll x, ll y) {
  return (y == 0 ? x : gcd(y, x % y));
}

ll lcm(ll x, ll y) {
    return (x*y)/gcd(x, y);
}

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

template<typename T>
bool diophantine(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + (T) ((__int128) x * (c / g) % b);
  y = dy + (T) ((__int128) y * (c / g) % a);
  g = abs(g);
  return true;
}

bool crt(long long k1, long long m1, long long k2, long long m2, long long &k, long long &m) {
  k1 %= m1;
  if (k1 < 0) k1 += m1;
  k2 %= m2;
  if (k2 < 0) k2 += m2;
  long long x, y, g;
  if (!diophantine(m1, -m2, k2 - k1, x, y, g)) {
    return false;
  }
  long long dx = m2 / g;
  long long delta = x / dx - (x % dx < 0);
  k = m1 * (x - dx * delta) + k1;
  m = m1 / g * m2;
  assert(0 <= k && k < m);
  return true;
}

void solve() {
  ll x, y, p, q;
  ll fans = LONG_LONG_MAX;
  cin >> x >> y >> p >> q;
  for(ll t1 = x;t1 < x+y;t1++) {
    for(ll t2 = p;t2 < p+q;t2++) {
      ll a = (2*x+2*y);
      ll b = p+q;
      // t%a=t1
      // t%b=t2
      // find minimum t if exist
      // t=i*a+t1=j*b+t2
      // i*a-j*b=t2-t1
      // sol : t%(lcm(a,b))=any solution
      ll x0, y0, g;
      // bool ans = find_any_solution(a, -b, t2-t1, x0, y0, g);
      ll t,m;
      bool ans = crt(t1,a,t2,b,t,m);
      if(!ans) continue;
      // ll an = (a*x0+t1)%(lcm(a,b));
      ll an = t;
      if(an < 0) an += lcm(a,b);
      fans = min(fans, an);

    }
  }
  if(fans == LONG_LONG_MAX) cout << "infinity" << endl;
  else cout << fans << endl;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int t = 1;
 cin >> t;
 while (t--) {
   solve();
 }

 return 0;
}

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

struct point
{
	ll x;
	ll y;
};

const ll MxN = 1e3+5;
point arr[MxN];

double dist(point a, point b)
{
	return sqrt((b.x - a.x)*(b.x - a.x) + (b.y-a.y)*(b.y-a.y));
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n; cin >> n;
	for (ll i=0; i<n; i++)
		cin >> arr[i].x >> arr[i].y;

	bool ans = 0;
	for (ll i=0; i<n-2; i++)
		for (ll j=i+1; j<n-1; j++)
			for (ll k=j+1; k<n; k++)
				if ((arr[k].x-arr[i].x)*(arr[j].y-arr[i].y) == (arr[j].x-arr[i].x)*(arr[k].y-arr[i].y))
				{
					ans = 1;
					break;
				}

	cout << (ans ? "Yes\n" : "No\n");

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 998244353;
const int maxn = 500+10;
const int red = 1;
const int blue = 2;

int a[maxn][maxn];

int32_t main(){
    fast_io;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
    	string s;
    	cin >> s;
    	for (int j = 0; j < m; ++j)
    	{
    		if(s[j] == 'R') a[i][j] = red;
    		else if(s[j] == 'B') a[i][j] = blue;
    	}
    }
    int ans = 1;
    for (int i = 0; i < n + m - 1; ++i)
    {
    	int r = 0, b = 0, avail = 0;
    	fo(j, 0, i){
    		int x = j, y = i - j;
    		if(x < 0 or x >= n or y < 0 or y >= m) continue;
    		if(a[x][y] == red) r++;
    		else if(a[x][y] == blue) b++;
    		else avail++;
    	}
    	if(r and b) {
    		pret(0);
    	}
    	if(avail){
    		if(r == 0 and b == 0){
    			ans = (ans * 2) % MOD;
    		}
    	}
    }
    show(ans);
    return 0;
}

#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
typedef long long ll;
cs int N = 505;
int n, m; char mp[N][N];
int c[N << 1];
int main() {
	#ifdef FSYo
	freopen("1.in", "r", stdin);
	#endif
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		scanf("%s", mp[i] + 1);
	memset(c, -1, sizeof c);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(mp[i][j] == 'R'){
				if(c[i + j] == 1)
					return puts("0"), 0;
				c[i + j] = 0;
			}
 			if(mp[i][j] == 'B') {
 				if(c[i + j] == 0)
 					return puts("0"), 0;
 				c[i + j] = 1;
 			}
 		}
	}
	int ans = 1;
	for(int i = 2; i <= n + m; i++)
	if(c[i] == -1) ans = (ans + ans) % 998244353;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

int64_t sqrt(int64_t x) {
    int64_t l = 0, r = 2e9;
    while (l < r) {
        int64_t m = (l + r) / 2;
        if (m * m > x) {
            r = m;
        }
        else {
            l = m + 1;
        }
    }
    return l - 1;
}

int64_t ceil(int64_t _x, int64_t _y) {
    if (_y < 0) {
        _x = -_x;
        _y = -_y;
    }
    if (_x < 0) return _x / _y;
    return (_x + _y - 1) / _y;
}

int64_t floor(int64_t _x, int64_t _y) {
    if (_y < 0) {
        _x = -_x;
        _y = -_y;
    }
    if (_x >= 0) return _x / _y;
    return (_x - _y + 1) / _y;
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    long double _x, _y, _r;
    std::cin >> _x >> _y >> _r;

    int64_t x = std::round(10000 * _x);
    int64_t y = std::round(10000 * _y);
    int64_t r = std::round(10000 * _r);

    int64_t c = ceill(_y - _r), d = floorl(_y + _r), ans = 0;

    for (int i = std::ceil(_x - _r); i <= std::floor(_x + _r); i++) {
        int64_t sq = sqrt(r * r - (10000 * i - x) * (10000 * i - x));

        int64_t e = std::max(ceil(y - sq, 10000), c);
        int64_t f = std::min(floor(y + sq, 10000), d);
        ans += std::max(f - e + 1, 0L);
    }

    printf("%jd\n", ans);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;

ll in() {
  ld x;
  cin >> x;
  x *= 10000;
  return round(x);
}

bool ok(ll dx, ll dy, ll z) { return dx * dx + dy * dy <= z * z; }

ll f(ll x, ll y, ll z, ll lim) {
  ll l = 0, r = 1, res = 0;
  for (int i = int(1e9) + 50000; i >= lim; i -= 10000) {
    while (ok(x - l * 10000, i - y, z)) l--;
    while (ok(r * 10000 - x, i - y, z)) r++;
    res += r - l - 1;
  }
  return res;
}

int main() {
  ll x = in();
  ll y = in();
  ll r = in();
  x %= 10000;
  y %= 10000;

  ll ans = f(x, y, r, 10000);
  ans += f(x, -y, r, 0);
  cout << ans << endl;
  return 0;
}


#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <random>
#include <chrono>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int A[3456][5];

bool check(int tg, int N) {
    vector<int> valid(1 << 5, 0);
    for (int i = 0; i < N; i++) {
        int mask = 0;
        for (int j = 0; j < 5; j++)
            if (A[i][j] >= tg)
                mask += (1 << j);
        valid[mask] = 1;
    }
    for (int i = 0; i < (1 << 5); i++) {
        if (!valid[i]) continue;
        for (int j = 0; j < (1 << 5); j++) {
            if (!valid[j]) continue;
            for (int k = 0; k < (1 << 5); k++) {
                if (!valid[k]) continue;
                if ((i | j | k) == (1 << 5) - 1)
                    return true;
            }
        }
    }
    return false;
}

int main() {
    int N;
    scanf("%d", &N);
    vector<int> V(5, 0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 5; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    int l = 0, r = (int)1e9, ans = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid, N)) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }

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

    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
by Benq;
*/

// 問題の URL を書いておく
//

#include <bits/stdc++.h>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = long long;

struct M
{
    int p[5];
};

bool check(int N, int s, vector<M>& ms)
{
    Print(s);
    vector<int> ts(N);
    rep(i, N)
    {
        auto v = 0;
        rep(j, 5)
        {
            if(ms[i].p[j] >= s)
            {
                v |= (1 << j);
            }
        }
        ts[i] = v;
    }
    sort(ts.begin(), ts.end());
    ts.erase(unique(ts.begin(), ts.end()), ts.end());

    auto c = (int)ts.size();

    if(c < 3)
    {
        auto v = 0;
        rep(i, c)
        {
            v |= ts[i];
            return v == (1 << 5) - 1;
        }
    }

    for(int i = 0; i < c - 2; ++i)
    {
        for(int j = i + 1; j < c - 1; j++)
        {
            for(int k = j + 1; k < c; ++k)
            {
                auto v = ts[i] | ts[j] | ts[k];
                if(v == (1 << 5) - 1)
                {
                    return true;
                }
            }
        }
    }

    return false;
}

int main(int, const char**)
{
    int N;
    cin >> N;

    vector<M> ms(N);
    rep(i, N) cin >> ms[i].p[0] >> ms[i].p[1] >>  ms[i].p[2] >> ms[i].p[3] >>  ms[i].p[4];

    int hi = 1000000001;
    int lo = 1;
    while(hi - lo > 1)
    {
        auto m = (hi + lo) / 2;
        Print(m);
        if(check(N, m, ms))
        {
            lo = m;
        }
        else
        {
            hi = m;
        }
    }

    cout << lo << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s,x;
	int n;
	bool is_t_win[200010][7] = {};
	cin >> n >> s >> x;
	is_t_win[n][0] = true;
	for(int i = 1;i < 7;i++) is_t_win[n][i] = false;
	int amari = 1;
	for(int i = n - 1;i >= 0;i--){
		for(int j = 0;j < 7;j++){
			if(x[i] == 'T'){
				is_t_win[i][j] = (is_t_win[i + 1][j] || is_t_win[i + 1][(j + (s[i] - '0') * amari) % 7]);
			}else{
				is_t_win[i][j] = (is_t_win[i + 1][j] && is_t_win[i + 1][(j + (s[i] - '0') * amari) % 7]);
			}
		}
		amari = amari * 10 % 7;
	}
	if(is_t_win[0][0]) cout << "Takahashi" << endl;
	else cout << "Aoki" << endl;
}

#include<bits/stdc++.h>
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,t,nxt[500002],pos,Nxt;
char a[500002],b[500002];
long long ans;
int main(){
	n=read();
	scanf("%s%s",a+1,b+1);
	for(re int i=n;i;--i){
		nxt[i]=pos;
		if(a[i]=='1')pos=i;
	}
	Nxt=nxt[1];
	for(re int i=2;i<=n;++i){
		if(a[i-1]^b[i-1]){
			re int pos=Nxt;
			if(!pos)return puts("-1"),0;
			ans+=pos-(i-1);
			a[pos]='0';
			Nxt=nxt[Nxt];
		}
		if(i==Nxt)Nxt=nxt[Nxt];
	}
	if(a[n]!=b[n])return puts("-1"),0;
	printf("%lld",ans);
}


#include <stdint.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR_N(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define FOR_R(i, b, e) for (int64_t i = int64_t(b); i < (int64_t)(e); i++)

int main() {
    int64_t A, B;
    cin >> A >> B;

    if (A + B >= 15 and B >= 8) {
        cout << 1 << endl;
    } else if (A + B >= 10 and B >= 3) {
        cout << 2 << endl;
    } else if (A + B >= 3) {
        cout << 3 << endl;
    } else {
        cout << 4 << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
  ll b,c;cin>>b>>c;
  ll ans=0;
  bool f=true;
  if(b<0) f=false;
  b=abs(b);

  if(b==0){
    ans=c;
  }else if(c>2*b){
    if(f) ans=2*b+c-1;
    else ans=2*b+c;
  }else if(c>=3){
    ans=2*c-1;
  }else{
    ans=c+1;
  }

  cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 2047483647
#define INFL 9223372036854775807
#define ll long long
#define pii pair<ll,ll>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ull unsigned long long
#define M 1000000007
//#define M 998244353
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define take(x) scanf("%d",&x)
#define DE(x) printf("\ndebug %d\n",x);
#define vout(x) for(int i=0;i<x.size();i++) printf("%d ",x[i]);
#define pie acos(-1)
#define MOD 998244353
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int main(){
    int n,a;
    cin>>n;
    int gcd = 0;
   // int ara[n];
    map<int,int> m;
    for(int i=0;i<15;i++) m[ primes[i] ] = 1;
    vector<int> ara;
    vector<ll> p;
    for(int i=0;i<n;i++){
        cin>>a;
     // a=i+2;
      if( m[a] == 0 ) ara.pb(a);
      else p.pb(a);
    }
    ll val = 0;
    for(int i=1;i<250;i++){
        bool pos = true;
        for(int j=0;j<ara.size();j++){
            if( __gcd(ara[j],i) == 1 ) pos = false;
        }
        if( pos ) {
            val = i;
            break;
        }
    }
    for(int i=0;i<p.size();i++){
        if( __gcd(p[i],val) == 1 ) val = val*p[i];
    }
    cout<<val;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define PLL pair<ll,ll>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vll (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define pu push
#define sz(x) int(x.size())
#define vij v[i][j]
// ll p = 1e9+7;
// ll p = 998244353;
// n do -> n*pi/180
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

vll prm;

int main(){
  int ma=52;
  vi pp(ma,1);

  rep(i,2,ma){
    if(pp[i]){
      prm.pb(i);
      rep(j,i+i,ma){
        pp[j]=0;
        j+=i-1;
      }
    }
  }

  cii(n);
  reciv(v,n);

  ll ans=3e18;

  int m=sz(prm);
  int m2=1<<m;

  rep(bn,0,m2){
    ll now=1;
    rep(i,0,m)if(bn>>i&1)now*=prm[i];

    int f=1;
    rep(i,0,n)if(__gcd(now,v[i])==1)f=0;

    if(f)chmin(ans,now);
  }

  co(ans);
}


#include <bits/stdc++.h>

#define repie( i, a, b ) for( i = a; i <= b; i ++ )

using namespace std;
using ll = long long;

int gcd( int a, int b ) {
    int c = max( a, b );
    int d = min( a, b );
    int e;
    while( c % d != 0 ) {
        e = c % d;
        c = d;
        d = e;
    }
    return d;
}

int main() {
    ll n, o = 1, i;
    cin >> n;
    repie( i, 2, n ) {
        o = ( o * i ) / gcd( o, i );
    }
    cout << ( o + 1 ) << endl;
    return 0;
}

//*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//*/

#include <bits/stdc++.h>

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
void YES(bool t=true) {cout<<(t?"YES":"NO")<<endl;}
void Yes(bool t=true) {cout<<(t?"Yes":"No")<<endl;}
void yes(bool t=true) {cout<<(t?"yes":"no")<<endl;}
void NO(bool t=true) {cout<<(t?"NO":"YES")<<endl;}
void No(bool t=true) {cout<<(t?"No":"Yes")<<endl;}
void no(bool t=true) {cout<<(t?"no":"yes")<<endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  if (b == 0) return a;
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return (a / gcd(a, b))*b;
}

signed main() {
    fio();

    int n;
    cin >> n;
    ll g = 1;
    for (int i = 2; i <= n; i++) g = lcm(g, i);

    ll now = 1;
    while (now < n) now += g;
    cout << now << endl;
}


#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 998244353;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

struct mint{ // auto MOD int
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD){}  //コンストラクタ
  mint operator-() const { return mint(-x); } //符号変換
  mint operator+(const mint &a) const { return mint(*this) += a; } //算術演算子
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  mint pow(ll n) const {  //繰り返し累乗
    if(!n) return 1;
    mint a = pow(n>>1);
    a *= a;
    if(n&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD-2); } // for prime mod
  mint& operator+=(const mint a){ if((x+=a.x) >= MOD) x-=MOD;  return *this; } //代入演算子
  mint& operator-=(const mint a){ if((x+=MOD-a.x) >= MOD) x-=MOD;  return *this; }
  mint& operator*=(const mint a){ (x *= a.x) %= MOD;  return *this; }
  mint& operator/=(const mint a){ return (*this) *= a.inv(); }
  friend ostream& operator<<(ostream &stout, const mint &tmp){ stout << tmp.x; return stout; }
};

class UnionFind{
public:
  vector<ll> parent;  //parent[i]はiの親
  vector<ll> siz;  //素集合のサイズを表す配列(1で初期化)
  UnionFind(ll n) : parent(n), siz(n,1){ rep(i,n) parent[i] = i; } //コンストラクタ  //全ての要素の根が自身であるとして初期化
  ll root(ll x){ //データxの属する木の根を取得(経路圧縮も行う)
    if(parent[x] == x) return x;
    return parent[x] = root(parent[x]);  //代入式の値は代入した変数の値なので、経路圧縮できる
  }
  void unite(ll x,ll y){ //xとyの木を併合
    ll rx = root(x);  //xの根
    ll ry = root(y);  //yの根
    if(rx == ry) return;  //同じ木にある時
    if(siz[rx] < siz[ry]) swap(rx,ry);
    siz[rx] += siz[ry];  //小さい集合を大きい集合へと併合(ry→rxへ併合)
    parent[ry] = rx;  //xとyが同じ木にない時はyの根ryをxの根rxにつける
  }
  bool same(ll x,ll y){ return root(x) == root(y); } //xとyが属する木が同じかを判定
  ll size(ll x){ return siz[root(x)]; } //xの素集合のサイズを取得
};

const int MAX = 1e6;
typedef vector<mint> vm;
struct comb {
  vm f, g;
  comb(){}
  comb(int mx):f(mx+1),g(mx+1) {
    f[0] = 1;
    for(int i = 1; i <= mx; ++i) f[i] = f[i-1]*i;
    g[mx] = f[mx].pow(MOD-2);
    for(int i=mx;i>0;i--) g[i-1] = g[i]*i;
  }
  mint operator()(int a, int b) {
    if (a < b) return 0;
    return f[a]*g[b]*g[a-b];
  }
} c(MAX);

int n,k;
vector<vi> a;
mint f(){
  UnionFind uf(n);
  rep(i,n) rep(j,i){
    bool ok = true;
    rep(K,n) if(a[i][K]+a[j][K] > k) ok = false;
    if(ok) uf.unite(i,j);
  }
  mint res = 1;
  rep(i,n) if(i == uf.root(i)) res *= c.f[uf.size(i)];
  return res;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >> n >> k;
  a = vector<vi>(n,vi(n)); rep(i,n) rep(j,n) cin >> a[i][j];
  mint ans = 1;
  rep(cnt,2){
    ans *= f();
    rep(i,n) rep(j,i) swap(a[i][j],a[j][i]);
  }
  cout << ans;
  cout << endl;
  return 0;
}

#include <iostream>
#include <algorithm>
#define MOD 998244353
int N, K;
int A[50][50];
int row_ok[50][50];
int col_ok[50][50];
long long num[51];
using namespace std;

long long calc(int line_ok[][50]) {
    long long ans = 1;
    int group[50];
    int groupN[50];
    for (int i=0; i<N; i++) group[i] = i;
    for (int i=0; i<N; i++) {
        groupN[i] = 0;
    }

    for (int _=0; _<=N; _++) {
        for (int i=0; i<N; i++) {
            for (int j=0; j<N; j++) {
                if (line_ok[i][j] == 1) {
                    int x = min(group[i], group[j]);
                    group[i] = group[j] = x;
                }
            }
        }
    }
    for (int i=0; i<N; i++) {
        groupN[group[i]]++;
    }
    for (int i=0; i<N; i++) {
        if (groupN[i] > 0) {
            ans *= num[groupN[i]];
            ans %= MOD;
        }
    }
    return ans;
}
int main() {
    {
        long long x = 1;
        for (int i=1; i<51; i++)
        {
            x *= i;
            x %= MOD;
            num[i] = x;
        }
    }

    cin >> N >> K;
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            cin >> A[i][j];
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            bool ok = true;
            for (int c=0; c<N; c++) {
                if (A[c][i] + A[c][j] > K) {
                    ok = false;
                    break;
                }
            }
            if (ok) col_ok[i][j] = 1;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            bool ok = true;
            for (int c=0; c<N; c++) {
                if (A[i][c] + A[j][c] > K) {
                    ok = false;
                    break;
                }
            }
            if (ok) row_ok[i][j] = 1;
        }
    }

    // row
    cout << (calc(row_ok) * calc(col_ok)) % MOD << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

// clang-format off
/* accelration */
// 高速バイナリ生成
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// cin cout の結びつけ解除, stdioと同期しない(入出力非同期化)
// cとstdの入出力を混在させるとバグるので注意
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

/* alias */
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;

/* define short */
#define pb push_back
#define mp make_pair
#define all(obj) (obj).begin(), (obj).end()
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

/* REP macro */
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

/* debug */
// 標準エラー出力を含む提出はrejectされる場合もあるので注意
#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;

/* func */
inline int in_int() {int x; cin >> x; return x;}
inline ll in_ll() {ll x; cin >> x; return x;}
inline string in_str() {string x; cin >> x; return x;}
// search_length: 走査するベクトル長の上限(先頭から何要素目までを検索対象とするか、1始まりで)
template <typename T> inline bool vector_finder(std::vector<T> vec, T element, unsigned int search_length) {
    auto itr = std::find(vec.begin(), vec.end(), element);
    size_t index = std::distance( vec.begin(), itr );
    if (index == vec.size() || index >= search_length) {return false;} else {return true;}
}
template <typename T> inline void print(const vector<T>& v, string s = " ")
    {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template <typename T, typename S> inline void print(const pair<T, S>& p)
    {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << "\n";}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v)
    {for (auto&& p : v) print(p);}
// 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

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

    vector<int> a(n);
    vector<int> b(n);

    rep(i, n) cin >> a[i] >> b[i];

    int mina = 1000000;
    int minb = 1000000;
    int ap;
    rep(i, n) {
        if(mina > a[i]) {
            mina = a[i];
            ap = i;
        }
    }
    b[ap] += mina;

    rep(i, n){
        if(minb > b[i]){
            minb = b[i];
        }
    }

    cout << max(mina, minb) << endl;

}


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

int main() {
  double sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  double ans;
  ans = ((sx * gy) + (gx * sy)) / (sy + gy);
  cout <<fixed<<setprecision(6)<< ans <<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << b - c << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  #ifdef _hogwarts
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  int n;
  cin >> n;
  int x = (n + 100) / 100;
  cout << (100 * x) - n << "\n";
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define MOD 1000000007

int main(void) {
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[1]+a[2] << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto &a : A) cin >> a, a %= 200;

    int cnt = min(N, 8);
    vector<int> v(200, -1);
    for (int bit = 1; bit < (1 << cnt); bit++) {
        int b = 0;
        for (int i = 0; i < cnt; i++) {
            if (bit & (1 << i)) b += A[i];
        }
        b %= 200;
        if (v[b] == -1)
            v[b] = bit;
        else {
            vector<int> B, C;
            for (int i = 0; i < cnt; i++) {
                if (bit & (1 << i)) B.push_back(i + 1);
                if (v[b] & (1 << i)) C.push_back(i + 1);
            }
            cout << "Yes" << endl;
            cout << B.size() << " ";
            for (auto i : B) cout << i << " ";
            cout << endl << C.size() << " ";
            for (auto i : C) cout << i << " ";
            cout << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

int n;
ll a[100005], b[100005];
ll dp[5][100005];

bool ok[5][5];

const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    ll ans = 0;
    for(int i = 0; i < n; i++) ans += a[i];
    priority_queue<ll> que_e, que_o;
    for(int i = 0; i < n; i++){
        if(i%2 == 0){
            que_e.push(b[i]-a[i]);
        }else{
            que_o.push(b[i]-a[i]);
        }
    }
    ll tmp = ans;
    while(!que_e.empty()){
        ll t0 = que_e.top(); que_e.pop();
        ll t1 = que_o.top(); que_o.pop();
        tmp += (t0+t1);
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}


/**
 * Author: kumasento
 * Date:   2021-05-22T13:24:20.000-05:00
 */

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

/// Types:
using LL = long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLI = pair<LL, int>;
using PLL = pair<LL, LL>;

/// Constants:
constexpr int INT_INF = 1000000000;
constexpr LL LL_INF = 10000000000000000LL;

/// Globals:
vector<vector<int>> children, lst;
vector<int> tin, tout, depth;
int timer;

/// Solution:

void dfs(int u) {
  tin[u] = timer ++;
  lst[depth[u]].push_back(tin[u]);
  for (int v : children[u]) {
    depth[v] = depth[u] + 1;
    dfs(v);
  }
  tout[u] = timer ++;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL_DEBUG
  ifstream in("E.in"); cin.rdbuf(in.rdbuf());
#endif

  int N; cin >> N;
  children.resize(N);
  lst.resize(N);
  tin.resize(N);
  tout.resize(N);
  depth.resize(N);

  for (int i = 1; i < N; ++ i) {
    int p; cin >> p;
    children[p - 1].push_back(i);
  }

  timer = 0;
  dfs(0);

  /// lst associates the depth with the in time of all nodes with that depth.

  int Q; cin >> Q;
  while (Q --) {
    int u, d; cin >> u >> d; u --;
    auto &v = lst[d];

    // Nodes enter time should be lower than tout[u], and >= tin[u].
    cout << (lower_bound(v.begin(), v.end(), tout[u]) -
             lower_bound(v.begin(), v.end(), tin[u])) << endl;
  }
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define ford(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define sz(s) (int)(s.size())
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
ll q_p(ll x,ll y){
	ll res=1;
	x%=mod;
	while(y){
		if(y%2){
			res=res*x;
			res%=mod;
		}
		y/=2;
		x=x*x;
		x%=mod;
	}
	re res;
}
bool ok(int x,int y,int n,int m){
	 re(x>=0&&x<n&&y>=0&&y<m);
}
bool isprime(int x){
	if(x<2)
	re false;
	for(int i=2;i*i<=x;i++)
	if(x%i==0)
	re false;
	re true;
}
int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
int ks[200001],js[200001];
int n,q;
vi v[200001];
int deep[200001];
int d[200001];
vector<pair<pii,int> > w;
int cnt=-1,B,num[200001];
void dfs(int x,int y){
	cnt++;
	deep[cnt]=y;
	ks[cnt]=cnt;
	num[x]=cnt;
	rep(i,sz(v[x]))
	dfs(v[x][i],y+1);
	js[num[x]]=cnt;
}
bool cmp(pair<pii,int> a,pair<pii,int> b){
	if(a.fr.fr/B!=b.fr.fr/B)
	re a.fr.fr/B<b.fr.fr/B;
	if(a.fr.se!=b.fr.se)
	re a.fr.se<b.fr.se;
	re a.fr.fr<b.fr.fr;
}
int ans[200001],now[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	B=sqrt(n);
	rep(i,n-1){
		int x;
		cin>>x;
		x--;
		v[x].pb(i+1);
	}
	dfs(0,0);
	cin>>q;
	rep(i,q){
		int x;
		cin>>x>>d[i];
		x--;
		w.pb(m_p(m_p(ks[num[x]],js[num[x]]),i));
	}
	sort(all(w),cmp);
	int nx=0,ny=-1;
	rep(i,q){
		while(ny<w[i].fr.se){
			ny++;
			now[deep[ny]]++;
		}
		while(ny>w[i].fr.se){
			now[deep[ny]]--;
			ny--;
		}
		while(nx<w[i].fr.fr){
			now[deep[nx]]--;
			nx++;
		}
		while(nx>w[i].fr.fr){
			nx--;
			now[deep[nx]]++;
		}
		ans[w[i].se]=now[d[w[i].se]];

	}
	rep(i,q)
	cout<<ans[i]<<"\n";
	re 0;
}
/*
检查循环是rep(i,n)还是rep(i,m)!!
long long所要的时间比int长!!
没有long long必要不写long long!!
写公式前先想一想!!
二分前看一看边界对不对，有没有特殊值!!
提交前要测特殊数据（边界上的）!!
*/


#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Futon | diff Futon.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Futon.cpp && ./a.out

/*

 10/10/2020

 5:02-

 */

const int MAX_N=1e2+1;
string S[MAX_N];
int N,M;

void solve() {
  int res=0;
  REP(i,N) REP(j,M) if(S[i][j]=='.') {
    if(i+1<N&&S[i+1][j]=='.') ++res;
    if(j+1<M&&S[i][j+1]=='.') ++res;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M;
  REP(i,N) cin>>S[i];
  solve();

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lli long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define plli pair<lli,lli>
#define vi vector<int>
#define vlli vector<lli>
#define vpi vector<pii>
#define vplli vector<plli>
#define mi map<int,int>
#define mlli map<lli,lli>
#define forl(i,a,b) for(lli i=a;i<b;i++)
#define ford(i,a,b) for(lli i=a;i>=b;i--)
#define cout0(a) cout << a << endl
#define cout1(a) cout << a << " "
#define cout2(a,b) cout << a << " " << b << endl
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl

lli gcd(lli a,lli b)
{
    if(b>a)
    {
      lli t=a;
      a=b;
      b=t;
    }

    while(b!=0)
    {
      lli t = a;
      a = b;
      b = t%b;
    }

    return a;
}

bool sortbysec(const pair<lli,lli> &a,const pair<lli,lli> &b)
{
    return (a.first < b.first);
}

void dfs(vlli v[],lli s,lli depth[],lli isvisited[])
{
  forl(i,0,v[s].size())
  {
    lli t=v[s][i];
    if(!isvisited[t])
    {
      depth[t]=depth[s]+1;
      isvisited[t]++;
      dfs(v,t,depth,isvisited);
    }
  }
}

lli nCr(lli n,lli r)
{
  lli p = 1,k = 1;
  if (n-r < r) r = n - r;

  if (r != 0)
  {
    while (r)
    {
      p*=n;
      k*=r;

      lli m = __gcd(p, k);

      p/=m;
      k/=m;

      n--;
      r--;
    }
  }
  else p = 1;

  return p;
}

lli SieveOfEratosthenes(lli n)
{
  bool prime[n+1];
  memset(prime,true,n+1);
  forl(i,2,n+1)
    if(prime[i])
      for(lli j=2*i;j<n+1;j+=i)
        prime[i]=false;

  lli count=0;
  forl(i,2,n+1)
    if(prime[i]) count++;
  return count;
}

int main()
{
  fastio;
  // time_t start, end;
  // time(&start);

  lli q;
  // cin >> q;
  q = 1;
  while(q--)
  {
    string s;
    cin >> s;

    lli n_o = 0, n_q = 0;

    forl(i,0,s.size())
    {
      if(s[i] == 'o') n_o++;
      else if(s[i] == '?') n_q++;
    }

    lli with_o[5];

    with_o[0] = 0;
    with_o[1] = 1;
    with_o[2] = 14;
    with_o[3] = 36;
    with_o[4] = 24;

    if(n_o > 4) cout0(0);
    else if(n_o == 4) cout0(24);
    else
    {
      lli max_req = 4-n_o;

      lli ans = 0;

      lli lim = min(max_req,n_q);

      forl(i,0,lim+1)
      {
        ans += nCr(n_q,i)*with_o[n_o+i];
      }

      cout0(ans);
    }
  }

  // time(&end);
  // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int NMAX = 200000;

int main() {
  int N; cin >> N;
  int A[NMAX];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  long long cumsum[NMAX + 1];
  cumsum[0] = 0;
  for (int i = 0; i < N; i++) {
    cumsum[i + 1] = cumsum[i] + A[i];
  }

  pair<int, long long> cumsum2[NMAX + 1];
  cumsum2[0] = make_pair(0, 0);
  for (int i = 0; i < N; i++) {
    cumsum2[i + 1] = make_pair(i, cumsum2[i].second + cumsum[i + 1]);
  }

  auto cmp = [](pair<int, long long> a, pair<int, long long> b) { return a.second < b.second; };
  sort(cumsum2, cumsum2 + N, cmp);

  int index = cumsum2[N - 1].first;
  long long pos = cumsum2[N - 1].second;
  long long ans = pos;
  for (int i = 0; i < index + 1; i++) {
    pos += A[i];
    ans = max(ans, pos);
  }

  ans = max(ans, cumsum2[N].second);
  cout << ans << endl;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#include <numeric>
#include <tuple>
#include <cassert>
#include <random>
#include <chrono>
#include <ext/rope>
#include <unordered_map>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define sz(x) (x).size()
#define lbt(x) ((x)&(-x))
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define fun function
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define pdi pair<double,int>
#define pdd pair<double,double>
#define mod 1000000007

#define int long long

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef rope<char> RPstring;
typedef __gnu_pbds::tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> RBtree;
/*rk = t.order_of_key(v)+1, get_k = *t.find_by_order(k)*/ /*idx begin of 0*/
typedef __gnu_pbds::priority_queue<pii,greater<pii>,pairing_heap_tag> PQ_pii_s;//small
typedef __gnu_pbds::priority_queue<pii,less<pii>,pairing_heap_tag> PQ_pii_b;//big
// gp_hash_table<T,T> x
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int tt;

inline int rd(){
  int x = 0, f = 1; char ch = getchar();
  while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
  while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}

void out(int a) {if(a<0)putchar('-'),a=-a;if(a>=10)out(a/10);putchar(a%10+'0');}
#define pnt(x) out(x),puts("")
#define put(x) out(x), putchar(' ')
#define putschar(x) putchar(x), puts("")

//int t[maxn];
//void upd(int p, int x) {for(;p<=n;p+=lbt(p))t[p]+=x;}
//int ask(int p) {int ret = 0;for(;p;p-=lbt(p))ret+=t[p];return ret;}

int bit_cnt(int x) {int res=0;while(x)res+=x&1,x>>=1;return res;}
int INT(string x, int sys) {int base=sys,res=0;for(auto i: x)res*=sys,res+=i-'0';return res;}//sys->10
string TNI(int x, int sys) {string res="";while(x)res+=x%sys+'0',x/=sys;reverse(all(res));return res;}//10->sys

int gcd(int a, int b) {return b?gcd(b,a%b):a;} int lcm(int a, int b) {return a*b/gcd(a,b);}
ll mul(ll a, ll b, int m) {ll ret = 0ll;while(b){if(b&1)ret+=a,ret%=m;a+=a,a%=m,b>>=1;}return ret;}
ll mul(ll a, ll b) {ll ret = 0ll;while(b){if(b&1)ret+=a;a+=a,b>>=1;}return ret;}
ll ksm(ll a, ll b, int m) {ll ret = 1ll;while(b){if (b&1) ret*=a,ret%=m;a*=a,a%=m,b>>=1;}return ret;}
ll ksm(ll a, ll b) {ll ret = 1ll;while(b){if(b&1)ret*=a;a*=a,b>>=1;}return ret;}
ll inv(ll x, int m) {return ksm(x,m-2,m);}

const int N = 1e5 + 10;
int dp[N], mi[26];
char s[N];

void run() {
  int n = rd();
  scanf("%s",s+1);
  mem(dp, inf);
  mem(mi, inf);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    int c = s[i] - 'a';
    for (int j = 0; j < 26; j++) {
      if (c == j) continue;
      dp[i] = min(dp[i], mi[j] + 1);
    }
    mi[s[i] - 'a'] = min(mi[s[i] - 'a'], dp[i - 1]);
  }
  cout << (dp[n] == INF ? -1 : dp[n]);
}

signed main(){
//  for (tt = rd(); tt--; )
  run();
  return 0;
}


// Problem:
// 			D - Orientation
//
//
// Contest: AtCoder - AtCoder Regular Contest 111
// URL: https://atcoder.jp/contests/arc111/tasks/arc111_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)

const int N = 105,M = N * N;
int g[N][N],a[M],b[M],c[N];
bool st[N];
int n,m;

void dfs(int u)
{
	st[u] = 1;
	forn(i,1,n)
	{
		if(!g[u][i])	continue;
		g[i][u] = 0;
		if(!st[i])	dfs(i);
	}
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
    forn(i,1,m)	cin >> a[i] >> b[i];
    forn(i,1,n)	cin >> c[i];

    vector<string> ans(m + 1,"");
    forn(i,1,m)
    {
    	if(c[a[i]] > c[b[i]])	ans[i] = "->";
    	else if(c[a[i]] < c[b[i]])	ans[i] = "<-";
    	else
    	{
    		g[a[i]][b[i]] = 1;
    		g[b[i]][a[i]] = 1;
    	}
    }

	forn(i,1,n)	if(!st[i])    dfs(i);
	forn(i,1,m)
	{
		if(ans[i] != "")	continue;
		if(g[a[i]][b[i]])	ans[i] = "->";
		else				ans[i] = "<-";
	}

	forn(i,1,m)	cout << ans[i] << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

int n, m;
int a[5055], b[5055];
int dir[5055];
int c[155];
bool used[155];
int dfn[155], t;

vector<pair<int, int>> g[155];

void dfs(int v) {
    used[v] = true;
    dfn[v] = t++;

    for (auto p: g[v]) {
        if (dir[p.second >> 1] == -1) {
            dir[p.second >> 1] = p.second & 1;
        }
        if (!used[p.first]) {
            dfs(p.first);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

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

    memset(dir, -1, sizeof(dir));

    for (int i = 0; i < m; i++) {
        if (c[a[i]] > c[b[i]]) {
            dir[i] = 0;
        }
        if (c[a[i]] < c[b[i]]) {
            dir[i] = 1;
        }
    }

    for (int i = 0; i < m; i++) if (dir[i] == -1) {
        g[a[i]].emplace_back(b[i], i * 2);
        g[b[i]].emplace_back(a[i], i * 2 + 1);
    }

    for (int i = 0; i < n; i++) if (!used[i]) {
        dfs(i);
    }

    for (int i = 0; i < m; i++) cout << (dir[i] == 0 ? "->" : "<-") << endl;
}


#define MOD 998244353
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,sw{0};
	int64_t ans{0};
	array < int64_t , 101 > fact;
	cin>>n;
	vector < int64_t > w(n);
	vector < array < int64_t , 10001 > > dp(n+1);
	fact[0]=1;
	dp[0].fill(0);
	for(int i=0; i<n; ++i){
		cin>>w[i];
		dp[i+1].fill(0);
		sw+=w[i];
	}
	dp[0][0]=1;
	for(int i=0; i<n; ++i){//element to be added
		for(int j=n-1; j>=0; --j){//size of current subset
			for(int k=0; k<dp[j].size()-w[i]; ++k){//weight of current subset
				dp[j+1][k+w[i]]+=dp[j][k];
				dp[j+1][k+w[i]]%=MOD;
			}
		}
	}
	for(int i=1; i<fact.size(); ++i){
		fact[i]=(i*fact[i-1])%MOD;
	}
	for(int i=0; i<dp.size(); ++i){
		ans+=(((dp[i][sw/2]*fact[i])%MOD)*fact[n-i])%MOD;
		ans%=MOD;
	}
	if(sw&1){
		cout<<0<<'\n';
	}
	else{
		cout<<ans<<'\n';
	}
}

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
//#pra gma G CC opti mize(3)
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x ) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
#define mod 998244353
ll dp[102][102][10005],a,n;
int main() {
	dp[0][0][5002]=1;
	F(iakioi,1,n=read()){
		read(a);
		#define j iakioi-i
		F(i,1,iakioi)F(k,1,10004-a){
			dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k+a])%mod;
		}
		F(i,0,iakioi-1)F(k,a+1,10004){
			dp[i][j][k]=(dp[i][j][k]+dp[i][j-1][k-a])%mod;
		}
		#undef j
	}ll ans=0;
	F(i,0,n){
		ll orz=1;ri j=n-i;
		F(k,1,i)orz=orz*k%mod;
		F(k,1,j)orz=orz*k%mod;
		ans+=orz*dp[i][j][5002]%mod;
	}
	cout<<ans%mod;
	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1000000007
#define mod2 998244353
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
#define sz(a) a.size()
#define checktime cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1)  res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll modAdd(ll a, ll b, ll p)
{
    return (a+b)%p;
}
ll modSub(ll a, ll b, ll p)
{
    return (a%mod - b%mod + mod)%p;
}
ll modMul(ll a, ll b, ll p)
{
    return (a*b)%p;
}

// ********** CODE STARTS HERE ****************//

void solve()
{
    int x,y,z;
    cin>>x>>y>>z;
    if(y*z % x == 0)cout<<y*z/x-1;
    else cout << y*z/x;
}
int main()
{
    // cout<<LONG_MAX;
	fastio;

        solve();

    // checktime;
	return 0;
}

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 1;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h)cin >> s[i];
	vector<string> t(h + w - 1);
	rep(i, h)rep(j, w)t[i + j].push_back(s[i][j]);
	modint ans = 1;
	rep(i, h + w - 1) {
		bool exib = false;
		bool exir = false;
		for (char c : t[i]) {
			if (c == 'R')exir = true;
			if (c == 'B')exib = true;
		}
		if (exir && exib)ans = 0;
		else if (!exir && !exib)ans *= 2;
	}
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//expr();
	//int t; cin >> t;rep(i, t)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define sz(v) (int)(v).size()
typedef long long LL;
typedef double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define int long long
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
void exgcd(int&x,int&y,int&d,int a,int b){
	if(!b)return x=1,y=0,d=a,void();
	exgcd(y,x,d,b,a%b),y-=a/b*x;
}

int a[5],b[5];
int mul(int x,int y,int mod){
	int res=0;
	while(y){
		if(y&1)(res+=x)%=mod;
		y>>=1,(x<<=1)%=mod;
	}
	return res;
}
int excrt(){
	int res=a[1],lcm=b[1];
	for(int i=2;i<=2;++i){
		int x,y,d,t=((a[i]-res)%b[i]+b[i])%b[i];
		exgcd(x,y,d,lcm,b[i]);
		if(t%d)return -1;
		res+=lcm*mul(x,t/d,b[i]/d);
		lcm=lcm/d*b[i];
		res=(res+lcm)%lcm;
	}
	return res;
}
signed main(){
	for(int T=read();T;--T){
		int x=read(),y=read(),p=read(),q=read(),ans=9e18;
		int t1=2*x+2*y,t2=p+q;
		rep(i,x,x+y-1){
			rep(j,p,p+q-1){
//				if((j-i)%d)continue;
//				exgcd(t1,-t2,A,B);
//				A=(A%t2+t2)%t2;
//				A=A*(j-i)/d,B=B*(j-i)/d;
//				ckmin(ans,t1*A+i);
				a[1]=i,b[1]=t1;
				a[2]=j,b[2]=t2;
				int t=excrt();
				if(t!=-1)ckmin(ans,t);
			}
		}
		if(ans==9e18)puts("infinity");
		else printf("%lld\n",ans);
	}
}

#include <bits/stdc++.h>

using namespace std;

#define pii pair<long long, long long>
#define FOR(x, j) for(int x = 0; x < j; x++)
typedef long long ll;

const int INF = 2e9;
const int maxN = 3e5+10;
const int LEAF = (1 << 19);
int TREE[2*LEAF];
int A[maxN];
int n, q;

void add(int x, int v){
    x += LEAF;
    while(x >= 1){
        TREE[x] ^= v;
        x /= 2;
    }
}

int query(int x){
    if(x < 0) return 0;
    x += LEAF;
    int ans = TREE[x];
    while(x > 1){
        if(x%2 == 1)
            ans ^= TREE[x-1];
        x /= 2;
    }
    return ans;
}

int query(int l, int r){
    return (query(r)^query(l-1));
}

void solve(){
    cin >> n >> q;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i < n; i++)
        add(i, A[i]);
    for(int i = 0; i < q; i++){
        int t, x, y;
        cin >> t >> x >> y;
        if(t == 1){
            add(x-1, y);
        }
        else
            cout << query(x-1, y-1) << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
   // multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


/////keep going!~!one day u will int get there
#include<bits/stdc++.h>
#define ll         	long long
#define pb        	push_back
#define ppb    	  	pop_back
#define pii         pair<ll int,ll  int>
#define vi   	  	vector<ll int>
#define YES  	  	cout<<"YES"<<endl;
#define NO   	  	cout<<"NO"<<endl;
#define all(a)    	(a).begin(),(a).end()
#define uniq(v)   	(v).erase(all int(v),(v).end())
#define rep(i,a,b)	 for(int i=a;i<b;i++)
#define repo(i,a,b) for(int i=a;i>=b;i--)
#define fi      first
#define se      second
#define endl    '\n'
const ll int maxn=1e5+10;
const ll int mod=1e9+7;
using namespace std;
//powerer function
long long int power(long long int a,long long int b)
{long long int res = 1;
        while(b>0){
                if(b%2==1) res = res * a;
                a = a*a;
                b = b/2;
        }
        return res;
}
//modular inverse
 ll int po( ll int x, ll int y){ ll int res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n,me;
    cin>>n>>me;
    vector < pair < int,pair<ll int,ll int> > > adj[n+1];
    for(int i=0;i<me;i++)
    {
    	ll x,y,a,b;
    	cin>>x>>y>>a>>b;
    	adj[x].pb({y,{a,b}});
    	adj[y].pb({x,{a,b}});
	}
	ll int t[n+1];
	for(int i=0;i<=n;i++)
	t[i]=1e17+1;
	t[1]=0;
	int v[n+1]={0};
	multiset < pair<ll int,int> > m;
	m.insert({0,1});
	while(m.size()>0)
	{
		pair < ll int,int> p=*m.begin();
		m.erase(m.begin());
		int node=p.se;
		ll int ct=p.fi;
		v[node]=1;
		if(t[node]<ct)
		continue;
		for(int i=0;i<adj[node].size();i++)
		{    int child=adj[node][i].fi;
		      ll int c=adj[node][i].se.fi,d=adj[node][i].se.se;
		      ll int val=1e17+1;
		      ll int sq=sqrt(d);
	          if(t[node]>sq+1)
	          val=t[node]+c+d/(t[node]+1);
	           else
	          for(int ti=max(t[node],sq-1);ti<=sq+1;ti++)
	          val=min(val,ti+c+d/(ti+1));
			if(!v[child]&&t[child]>val)
			{
				t[child]=val;
				m.insert({val,child});
			}
		}

	}
	if(t[n]==1e17+1)
	cout<<"-1"<<endl;
	else
	cout<<t[n]<<endl;

  }
}

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <string>
#include <sstream>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using P=pair<ll,ll>;
const ll INF=1e18;
const int mod=1e9+7;

struct edge{
  int to;
  ll c,d;
  edge(int to,ll c,ll d):to(to),c(c),d(d){}
};
using Graph=vector<vector<edge>>;

void solve(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  rep(i,m){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    G[a].emplace_back(b,c,d);
    G[b].emplace_back(a,c,d);
  }

  vector<ll>dist(n,INF);
  dist[0]=0;
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
  q.push({dist[0],0});
  while(!q.empty()){
    int v=q.top().second;
    ll tm=q.top().first;
    q.pop();
    if(tm>dist[v]){continue;}
    for(auto e:G[v]){
      ll t=max(0ll,(ll)(sqrt(e.d)-1-tm));
      ll t2=max(0ll,(ll)(sqrt(e.d)-tm));
      ll add=min(t+e.c+e.d/(tm+t+1),t2+e.c+e.d/(tm+t2+1));
      if(chmin(dist[e.to],tm+add)){q.push({dist[e.to],e.to});}
    }
  }
  //rep(i,n){cout<<dist[i]<<endl;}
  ll ans=dist[n-1];
  if(ans==INF){ans=-1;}
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}


#include<bits/stdc++.h>
using namespace std;
#define INFTY (1<<29)
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
using lpair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const ll MOD=998244353;
const ll MAX = 5100000;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
    int n,sum = 0;cin>>n;
    vector<int> t(n);
    rep(i,n){
        cin>>t[i];
        sum += t[i];
    }
    vector<int> cook(sum+1,0);
    cook[0] = 1;
    rep(i,n){
        vector<int> new_cook = cook;
        rep(j,sum+1){
            if(cook[j]){
                //cout<<j<<endl;
                new_cook[j+t[i]] = 1;
            }
        }
        cook = new_cook;
    }

    int ans = 100010;
    for(int i = 1;i<=sum;i++){
        if(cook[i]){
            ans = min(ans,max(i,sum-i));
        }
    }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<ll> c(n + 1);
  c[0] = 0;
  REP(i, n) {
    if (i % 2 == 0) c[i + 1] = c[i] + a[i];
    else
      c[i + 1] = c[i] - a[i];
  }
  map<ll, ll> mp;
  FOR(i, 0, n) mp[c[i]]++;
  ll ans = 0;
  EACH(e, mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define For(i,a,b,c) for(ll i=a;i<b;i+=c)
#define For2(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define vec_ll vector<vector<ll>>
#define vec_pr vector<pair<ll,ll>>
#define pr pair<ll,ll>
#define pbk push_back
#define mkpr make_pair
#define fst first
#define snd second

void print(ll *arr, ll n){
    For(i,0,n,1)cout<<arr[i]<<" ";
    cout<<endl;
}

bool s_sec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll fast_expo(ll a, ll p){
    //cout<<a<<" ";
    ll x=p-2;
    ll curr=a;
    ll ans=1;
    while(x!=0){
        if(x%2==1){
            ans=(ans*curr)%p;
        }
        x/=2;
        curr=(curr*curr)%p;
    }
    return ans;
}

void solve(string &s, ll n, vector<ll> &ans){
    ll pref[n+1],suff[n+1];

    ///pref
    if(s[0]=='R'){
        pref[1]=1;
    }
    else{
        pref[1]=0;
    }

    For(i,1,n,1){
        if(s[i]=='R'){
            if(s[i-1]=='R'){
                pref[i+1]=1;
            }
            else{
                pref[i+1]=pref[i]+1;
            }
        }
        else{
            if(s[i-1]=='R'){
                pref[i+1]=pref[i]+1;
            }
            else{
                pref[i]=0;
            }
        }
    }

    ll mark_r[n+1];
    ll cnt=n;
    For(i,n,1,1){
        mark_r[i]=cnt;
        if(pref[i]==0){
            cnt=i;
        }
    }
    mark_r[0]=cnt;

    ///suff
    if(s[n-1]=='L'){
        suff[n-1]=1;
    }
    else{
        suff[n-1]=0;
    }

    For2(i,n-2,0,1){
       if(s[i]!=s[i+1]){
            suff[i]=suff[i+1]+1;
       }
       else{
            if(s[i]=='L'){
                suff[i]=1;
            }
            else{
                suff[i]=0;
            }
       }
    }

    ll mark_l[n+1];
    cnt=0;
    For(i,0,n,1){
        mark_l[i]=cnt;
        if(suff[i]==0){
            cnt=i;
        }
    }
    mark_l[n]=cnt;

    ans.pbk(mark_r[0]);
    For(i,1,n,1){
        ans.pbk(mark_r[i]-mark_l[i]-1);
    }
    ans.pbk(suff[n]);

    return ;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    /*ll T,p=1000000007;
    cin>>T;

    ll fact[1001],inverse[1001];
    fact[0]=fact[1]=inverse[0]=inverse[1]=1;

    For(i,2,1001,1){
        fact[i]=(fact[i-1]*i)%p;
        inverse[i]=fast_expo(fact[i],p);
    }*/

    /*ll T;
    cin>>T;

    while(T--){
        ll n;
        cin>>n;

        string s;
        cin>>s;

        vector<ll> ans;
        solve(s,n,ans);

        For(i,0,n+1,1)cout<<ans[i]<<" ";
        cout<<"\n";
    }*/

    ll N;
    cin>>N;
    ll lim=2*N;

    ll root=sqrt(lim);
    ll ans=0;

    For(i,1,root+1,1){
        ///Check if answer is possible
        if(lim%i==0){
            ll fact[2]={i,lim/i-1};

            ll x=(fact[0]+fact[1]), y=(fact[1]-fact[0]);
            if(x%2==0&&y%2==0)ans++;
        }
    }

    cout<<2*ans;
}

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

long long mod_pow(long long x, long long y, long long M){
    if(y == 0){
        return 1;
    }
    if(y & 1){
        return mod_pow(x, y - 1, M) * x % M;
    }
    long long t = mod_pow(x, y / 2, M);
    return t * t % M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    char c0,c1,c2,c3;
    cin >> N >> c0 >> c1 >> c2 >> c3;
    if(N<=3){
        cout << 1 << endl;
        return 0;
    }
    string s="";
    s+=c0;
    s+=c1;
    s+=c2;
    s+=c3;
    if(s=="ABAA"||s=="BABA"||s=="BABB"||s=="BBAA"){
        cout << mod_pow(2,N-3,MOD) << endl;
    }
    else if(s=="ABBA"||s=="BAAA"||s=="BAAB"||s=="BBBA"){
        vl dp(10000,0);
        dp[2]=dp[3]=1;
        FOR(i,4,10000){
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=MOD;
        }
        cout << dp[N] << endl;
    }
    else{
        cout << 1 << endl;
    }
}


/*         ====Bismillahir Rahmanir Rahim=====

                    ===ImRan Hossen===

    ==Bangladesh University Of Business And Technology==

*/

#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#include <ctime>
using namespace std;

template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T sq(T x) { return x * x; }

#define pocount     __builtin_popcountll
#define pf          printf
#define PB          push_back
#define MP          make_pair
#define fi          first
#define se          second
#define MOD         1000000007
#define si(a)       scanf("%d",&a)
#define sii(a,b)    scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define sl(a)       scanf("%lld",&a)
#define sll(a,b)    scanf("%lld%lld", &a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld", &a, &b, &c)
#define ss(s)	    scanf("%s",s)
#define RESET(a, b) memset(a, b, sizeof(a))

#define all(v)      v.begin(),v.end()
#define rall(v)     v.rbegin(),v.rend()
#define SORT(v)     sort(all(v))
#define REVERSE(v)  reverse(all(v))
#define PERMUTE     next_permutation
#define TC(t)       while (t--)

#define FOR(a, b, c)    for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c)   for (int(a) = (b); (a) <= (c); ++(a))
#define REP(i, n)       FOR(i, 0, n)
#define REPN(i, n)      FORN(i, 1, n)
#define SET(p)          memset(p, -1, sizeof(p))
#define CLR(p)          memset(p, 0, sizeof(p))
#define MEM(p, v)       memset(p, v, sizeof(p))
#define SZ(c)           (int)c.size()

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif

#define FasterIO    ios_base::sync_with_stdio(false); cin.tie(NULL);

const double pi = acos(-1.0);

typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;

int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };

class TimeTracker {
    clock_t start, end;
public:
    TimeTracker() {
        start = clock();
    }
    ~TimeTracker() {
        end = clock();
        fprintf(stderr, "%.3lf s\n", (double)(end - start) / CLOCKS_PER_SEC);
    }
};

int main()
{
    //FaterIO

    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	///TimeTracker a;

	int n, A[1010], mark[1010], i, flag;

	scanf("%d", &n);

        flag = 0;

        CLR(mark);

        for(i = 0; i < n; i++){
            scanf("%d",&A[i]);
            if(mark[A[i]]>0)flag = 1;
            mark[A[i]]++;
        }

        if(flag)
        {
            printf("No\n");
        }
        else printf("Yes\n");

    return 0;
}

//Don't Get panic
//Take it easy
//what about n=1 or n=2 and corner case and also critical case
//If failed in system test read the problem again
//Bug is part of code

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

#define debug(x) cerr << #x << '=' << x << endl
#define rep(i, b, e) for (int i = b; i <= e; i++)

char ss1[512345], ss2[512345];
char s1[512345], s2[512345];

int work(char *s1, char *s2, int n) {
    vector<int> a(1), b(1);
    int ans = 0;
    rep (i, 1, n) {
        if (s1[i] == '0') {
            a.push_back(i);
        }
        if (s2[i] == '0') {
            b.push_back(i);
        }
    }
    rep (i, 0, a.size() - 1) {
        if (a.at(i) != b.at(i)) {
            ans++;
        }
    }
    return ans;
}
int main(void) {
    int n, cnt = 0;
    cin >> n;
    scanf("%s%s", ss1 + 1, ss2 + 1);
    rep (i, 1, n) {
        s1[i] = ss1[i];
        s2[i] = ss2[i];
    }
    rep (i, 1, n) {
        if (ss1[i] == '0') {
            cnt++;
        }
        if (ss2[i] == '0') {
            cnt--;
        }
    }
    if (cnt != 0) {
        puts("-1");
        return 0;
    }
    int ans = work(s1, s2, n);
    cout << ans;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

string cout_vector_separator = " ";
template<typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
    bool is_first = true;
    for (const auto& i : v) {
        if (is_first) is_first = false;
        else s << cout_vector_separator;
        s << i;
    }
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x, a;
    cin >> n >> x;
    vector<int> b;
    b.reserve(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a != x) b.push_back(a);
    }
    cout << b << '\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int a[maxn],n,k;
int main() {
	scanf("%d%d",&n,&k);
	for(register int i=1; i<=n; i++) {
		scanf("%d",&a[i]);
		if(a[i]==k)i--,n--;
	}
	for(register int i=1; i<=n; i++)printf("%d ",a[i]);
	return 0;
}