#include "bits/stdc++.h"
#define rep(var,init,max) for(int (var)=(init); (var) < (max); ++(var))
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).begin(),(v).end()),reverse((v).begin(),(v).end())
using namespace std;

using ll = long long;
using ull = unsigned long long;

const int mod107 = 1e9 + 7;
const int mod998 = 998244353;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vector<T>>;

bool debugflag = false;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	for (int i = 0; i < (int)v.size(); ++i) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& in : v) is >> in;
	return is;
}

template<typename T>
ostream& operator<<(ostream& os, const mat<T>& v) {
	for (int i = 0; i < (int)v.size(); ++i) {
		os << v[i] << endl;
	}
	return os;
}

void debug() {
	cout << endl;
}

template<class Head, class... Tail>
void debug(Head&& head, Tail&&... tail) {
	if (!debugflag) return;
	cout << head << " ";
	debug(forward<Tail>(tail)...);
}

template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }

    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream& operator<<(ostream& os, const ModInt& p) {
        return os << p.x;
    }

    friend istream& operator>>(istream& is, ModInt& a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt< mod998 >;

template<typename T>
T gcd(T x, T y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y) {
    return x / gcd(x, y) * y;
}

int main() {
    int N; cin >> N;
    vec<int> A(N); cin >> A;
    int ans = 0;
    rep(i, 0, N) {
        ans += max(0, A[i] - 10);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a <= 10)
        {
            continue;
        }
        else
        {
            count += a - 10;
        }
    }
    cout << count;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int sizeRes=0;
vector<pair<int,int> > res;
bool mergeSort(vector<int> &v, int from, int to, bool rev) {
   if(from==to) return true;
    if(rev) {
        for(int c=from;c<to;c++) {
            if(v[c+1]<=c && v[c] >= c+1) {
                res[sizeRes++]=(make_pair(c,c+1));
                swap(v[c],v[c+1]);
                if(!mergeSort(v,from,c,false)) return false;
                if(!mergeSort(v,c+1,to,true)) return false;
                return true;
            }
        }
    } else {
        for(int c=to-1;c>=from;c--) {
            if(v[c+1]<=c && v[c] >= c+1) {
                res[sizeRes++]=(make_pair(c,c+1));
                swap(v[c],v[c+1]);
                if(!mergeSort(v,from,c,false)) return false;
                if(!mergeSort(v,c+1,to,true)) return false;
                return true;
            }
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    vector<int> v(N);
    res.resize(N-1);
    for(int c=0;c<N;c++) {
        cin>>v[c];
        v[c]--;
    }

    if(!mergeSort(v,0,N-1,true)) {
        cout<<-1;
        return 0;
    }
    for(int c=0;c+1<v.size();c++) {
        if(v[c]>v[c+1]) {
            cout<<-1;
            return 0;
        }
    }
    for(auto z:res) {
        cout<<z.first+1<<"\n";
    }

}

#pragma warning(disable:4996)
#include <stdio.h>
#include <set>
using namespace std;
set<int> a;
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int c;
		scanf("%d", &c);
		a.insert(c);
	}
	while (*a.begin() != *(--a.end()))
	{
		int mn = *a.begin();
		int mx = *(--a.end());
		a.erase(mx);
		a.insert(mx - mn);
	}
	printf("%d", *a.begin());
}


/*
15
63 25 66 36 39 29 93 3 188 128 191 82 179 178 168
*/
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

using State = pair<pii, bool>;

vi a;
// what cases do i have to handle?
// if the mod = 0, need to not count degenerate one
vi solve(vector<vector<vector<State>>>& prev, pii initial, bool ig) {
	vi ans;

	int whichDefault = (ig ? -1 : -2);
	bool once = false;
	while(initial != mp(-1, -1)) {
		int row = initial.first;
		int col = initial.second;
		//cout << row << " " << col << endl << flush;
		int len = sz(prev[row][col]);
		if(len + whichDefault >= 0) {
			// cout << len << " " << whichDefault << endl << flush;
			//assert(len + whichDefault < len);
			State taken = prev[row][col][len + whichDefault];
			if(taken.second) {
				ans.pb(taken.first.first + 1);
			}

			initial = taken.first;

			if(!once) {
				whichDefault = -1;
				once = true;
			}

		} else {
			// take 0
			State taken = prev[row][col][0];
			// it means that to get to the current state, we took from the previous one
			if(taken.second) {
				ans.pb(taken.first.first + 1);
			}
			initial = taken.first;
		}
	}
	reverse(all(ans));
	return ans;
}

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

	// if there exists 2 different elements = x mod 200, then obv

	int n; cin >> n;
	a.resize(n); trav(x, a) cin >> x;

	map<int,vector<int>> cnt;
	for(int i = 0; i < n; i++) {
		cnt[a[i] % 200].pb(i);
	}

	trav(p, cnt) {
		if(sz(p.second) >= 2) {
			cout << "Yes" << endl;
			cout << 1 << " " << p.second[0] + 1 << endl;
			cout << 1 << " " << p.second[1] + 1 << endl;
			return 0;
		}
	}

	// includes the dummy subsequence
	vector<vector<ll>> dp(n + 1, vector<ll>(200, 0));
	vector<vector<vector<State>>> prev(n + 1, vector<vector<State>>(200));
	dp[0][0] = 1;
	prev[0][0].pb({mp(-1,-1), false});

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 200; j++) {
			ll here = dp[i][j];
			if(here != 0) {
				// include this element
				dp[i + 1][(j + a[i]) % 200] += here;
				if(prev[i + 1][(j + a[i]) % 200].size() <= 3) {
					prev[i + 1][(j + a[i]) % 200].pb({mp(i, j), true});
				}
				dp[i + 1][j] += here;
				if(prev[i + 1][j].size() <= 3) {
					prev[i + 1][j].pb({mp(i,j), false});
				}
			}
		}
	}

	vi b, c;
	for(int j = 0; j <= n; j++) {
		for(int i = 0; i < 200; i++) {
			if(i == 0) {
				if(dp[j][i] >= 3) {
					cout << "Yes" << endl;
					b = solve(prev, {n, i}, false);
					c = solve(prev, {n, i}, true);
					cout << sz(b) << " "; trav(x, b) cout << x << " ";
					cout << endl;
					cout << sz(c) << " "; trav(x, c) cout << x << " ";
					cout << endl;
					return 0;
				}
			} else {
				if(dp[j][i] >= 2) {
					cout << "Yes" << endl;
					b = solve(prev, {n, i}, false);
					c = solve(prev, {n, i}, true);
					cout << sz(b) << " "; trav(x, b) cout << x << " ";
					cout << endl;
					cout << sz(c) << " "; trav(x, c) cout << x << " ";
					cout << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define fit(i,x) for(auto i=x.begin() ; i != x.end() ; i++)
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=3e3+5;
const int INF=1e9;
const int MOD=998244353;

ll dp[M][M<<1];

int main(){

	fastio;
	int n,k; cin >> n >> k;
	dp[0][0] = 1;

	fp(i,1,M)
		fn(j,i,1){
			dp[i][j] = dp[i-1][j-1];
			if (2*j <= i) dp[i][j] = (dp[i][j] + dp[i][j<<1]) % MOD;
		}

	cout << dp[n][k] << "\n";

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

// auto mod int
//const int mod = 1000000007;
//const int mod = 998244353;
int mod;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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) 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 t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  //mint inv() const { return pow(mod-2);}

  //supports not prime
  mint modinv(ll a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    mint res(u);
    return res;
}
  mint& operator/=(const mint a) { return *this *= modinv(a.x);}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int N,K;
    cin>>N>>K>>mod;

    int MX=N*(N+1)*K/2+1;

    vector<vector<mint>> dp(N+1, vector<mint> (MX));
    dp[0][0]=1;
    int s=0;
    for(int i=1;i<=N;i++){
        vector<mint> ps(i);
        s+=i;
        for(int j=0;j<=s*K;j++){
            int x=j%i;
            ps[x]+=dp[i-1][j];
            if(j-i*(K+1)>=0){
                ps[x]-=dp[i-1][j-i*(K+1)];
            }
            dp[i][j]=ps[x];
        }
    }

    s=0;

    for(int i=1;i<=N;i++){
        s+=i;
        mint ans;
        for(int t=0;t<=s*K;t++){
            ans+=dp[i-1][t]*dp[N-i][t];
        }
        ans=ans*(K+1)-1;
        cout<<ans<<endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll maxN = 880;

ll N, K, C;
ll A[maxN][maxN], S[maxN][maxN];

bool OK(ll X) {
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            if (A[i][j]>X) S[i][j] = 1;
            else S[i][j] = 0;
        }
    }
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            S[i][j] += S[i][j-1];
        }
    }
    for (ll j=1; j<=N; j++) {
        for (ll i=1; i<=N; i++) {
            S[i][j] += S[i-1][j];
        }
    }
    for (ll i=K; i<=N; i++) {
        for (ll j=K; j<=N; j++) {
            ll cnt = S[i][j] - S[i-K][j] - S[i][j-K] + S[i-K][j-K];
            if (cnt<C) return true;
        }
    }
    return false;
}

int main() {
    cin >> N >> K;
    C = K*K/2 + 1;
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            cin >> A[i][j];
        }
    }
    ll l = -inf, r = inf;
    while (r-l>1) {
        ll m = (l+r)/2;
        if (OK(m)) r = m;
        else l = m;
    }
    Cout(r);
}


#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stack>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F(i, n) for (int i = 0; i < n; i++)
#define Fa(n, a) for (int i = 0; i < n; i++) a[i] = gi()
#define R(i, n) for (int i = n-1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007
#define PI 3.141592653589793238462643383279502884L
#define EP 0.000000001L

int within(double a, double b) {
    return (a >= b - EP && a <= b + EP);
}

void rotate(double &x, double &y, double r) {
    double l = sqrt(x*x + y*y);
    double a = atan2(y, x) + r;
    if (a > PI)
        a -= 2.0L * PI;
    if (within(a, PI * 0.5L)) {
        x = 0;
        y = l;
        return;
    }
    if (within(a, PI * -0.5L)) {
        x = 0;
        y = -l;
        return;
    }
    if (within(a, 0)) {
        x = l;
        y = 0;
        return;
    }
    if (within(a, PI) || within(a, -PI)) {
        x = -l;
        y = 0;
        return;
    }
    y = tan(a);
    x = 1;
    if (a <= PI * -0.5L || a > PI * 0.5L) {
        x *= -1.0L;
        y *= -1.0L;
    }
    double z = sqrt(x*x + y*y);
    x *= l/z;
    y *= l/z;
}

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

    I(n);
    II(double x);
    II(double y);
    II(double X);
    II(double Y);
    X = (x + X) * 0.5L;
    Y = (y + Y) * 0.5L;

    x -= X;
    y -= Y;

    double r = PI / double(n/2);

    rotate(x, y, r);

    cout << setprecision(10) << x+X << " " << y+Y << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repit(i,C) for (auto i = (C).begin(); i != (C).end(); i++)
#define pr(a) cout << a
#define prl(a) cout << (a) << endl
#define prld(a) cout << setprecision(15)<< (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,N){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    reps(i,1,N){
        int dx = S[i].first - pt0.first;
        int dy = S[i].second - pt0.second;
        int x=dx*a-dy*b;
        int y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

int main(){
    std::cin.tie(0); // cinとcoutの同期を解除
    std::ios::sync_with_stdio(false);
    int N;cin >> N;

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
/*    vector<vector<int>> tri(12);
    tri[0]={0,1,1};
    tri[1]={-1,0,1};
    tri[2]={0,-1,1};
    tri[3]={1,0,1};
    tri[4]={3,4,5};
    tri[5]={4,3,5};
    tri[6]={-3,4,5};
    tri[7]={-4,3,5};
    tri[8]={-3,-4,5};
    tri[9]={-4,-3,5};
    tri[10]={3,-4,5};
    tri[11]={4,-3,5};*/

    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));

 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

    bool flg;

    if(S.size()==2 && T.size()==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,tri.size()){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}


#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H)cin >> S[i];
  vector<llvec> L(H+1, llvec(W+1, 0));
  vector<llvec> R(H+1, llvec(W+1, 0));
  vector<llvec> U(H+1, llvec(W+1, 0));
  vector<llvec> B(H+1, llvec(W+1, 0));
  rep(i, H){
    rep(j, W){
      U[i+1][j] = U[i][j] + 1;
      if(S[i][j]=='#')U[i+1][j]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      B[H-i-1][j] = B[H-i][j] + 1;
      if(S[H-i-1][j]=='#')B[H-i-1][j]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      L[i][j+1] = L[i][j] + 1;
      if(S[i][j]=='#')L[i][j+1]=0;
    }
  }
  rep(i, H){
    rep(j, W){
      R[i][W-j-1] = R[i][W-j] + 1;
      if(S[i][W-j-1]=='#')R[i][W-j-1]=0;
    }
  }
  ll m=0;
  rep(i, H)rep(j, W)if(S[i][j]=='.')m++;
  /*
  cerr << m << endl;
  rep(i, H){DUMP(k, L[i]);cerr << endl;}
  rep(i, H){DUMP(k, R[i]);cerr << endl;}
  rep(i, H){DUMP(k, U[i+1]);cerr << endl;}
  rep(i, H){DUMP(k, B[i]);cerr << endl;}*/
  ll ans = 0;
  rep(i, H){
    rep(j, W){
      if(S[i][j]=='.'){
        ll c = L[i][j+1]+U[i+1][j] + B[i][j] + R[i][j] - 3;
        ans = mod(ans + mod(modpow(2, m-c, MOD)*(modpow(2,c, MOD)-1), MOD), MOD);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair

using namespace std;

#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 foreach(itr, c) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

typedef long long LL;
typedef pair <int, int> pii;
typedef vector <int> vi;

const int N = 105;
const int M = 1e4 + 5;

int n, m, a[M], b[M], c[N];
vi e[N];
set <int> e2[N];
bool vis[N];

void dfs(int now, int from){
    vis[now] = 1;
    for (auto u : e[now]) if (u != from && c[u] == c[now]){
        if (e2[u].find(now) != e2[u].end()) continue;
        e2[now].insert(u);
        if (!vis[u]) dfs(u, now);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, m){
        scanf("%d%d", &a[i], &b[i]), a[i]--, b[i]--;
        e[a[i]].PB(b[i]);
        e[b[i]].PB(a[i]);
    }
    rep(i, n) scanf("%d", &c[i]);
    rep(i, m){
        if (c[a[i]] > c[b[i]]) e2[a[i]].insert(b[i]);
        else if (c[a[i]] < c[b[i]]) e2[b[i]].insert(a[i]);
        else {
            if (e2[a[i]].find(b[i]) != e2[a[i]].end() || e2[b[i]].find(a[i]) != e2[b[i]].end())
                continue;
            dfs(b[i], a[i]);
        }
    }

    rep(i, m){
        if (e2[a[i]].find(b[i]) != e2[a[i]].end()) printf("->\n");
        else printf("<-\n");
    }
    return 0;
}

#include <bits/stdc++.h>
// #define int long long
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ti tuple<int, int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) (((a)+(b)-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 200010;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-8;
const ld PI = acos(-1);

// End Template //

int c[MAX];
bool ans[MAX];
vi alc(MAX, 1);
vector<vi> g(MAX);
bool visto[MAX];
map<pii, pii> edg; // (a,b) -> (direita, idx)

void dfs(int u){
    if(visto[u]) return;
    visto[u]=true;
    for(auto v: g[u]){
        // if(visto[v]){
        //     pii e = mm[{}];
        // }else{

        // }
        pii e = edg[{u, v}];
        ans[e.ss] = e.ff;
        dfs(v);
    }
}

int32_t main()
{sws;

    int n, m, u, v;
    cin >> n >> m;
    vii ee;
    for(int i=0;i<m;i++){
        cin >> u >> v; u--;v--;
        ee.pb({u, v});
    }
    for(int i=0;i<n;i++)
        cin >> c[i];

    for(int i=0;i<m;i++){
        int u=ee[i].ff, v=ee[i].ss;
        if(c[u]!=c[v]){
            ans[i] = (c[u] > c[v]);
            continue;
        }
        g[u].pb(v);
        g[v].pb(u);
        edg[{u, v}] = {1, i};
        edg[{v, u}] = {0, i};
    }

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

    // output
    for(int i=0;i<m;i++){
        if(ans[i])
            cout << "->\n";
        else
            cout << "<-\n";
    }

    return 0;
}


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

int main() {
  double A, B;
  cin >> A >> B;
  double ans = 0;
  ans = A * B / 100;
  cout << ans << endl;
}

#include <bits/stdc++.h>

#define ll long long
#define fo(a,b,c) for(int a=b;a<=c;a++)

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int c=n,d=k;
    int a=0,b=0;;
    while(n){
        a+=n;
        n--;
    }
    while(k){
        b+=k;
        k--;
    }
    b*=c;
    a*=d;

    cout<<a*100+b;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define int long long
unsigned long long n;
int a,b;
int C[100][100];
signed main()
{
	cin>>a>>b>>n;
	C[1][0]=1,C[1][1]=1;
	for(int i=2;i<=60;i++)
	{
		for(int j=0;j<=i;j++)
		{
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
	while(a>=1&&b>=1)
	{
		if(n>C[a-1+b][b]) n-=C[a-1+b][b],putchar('b'),b--;
		else putchar('a'),a--;
//		cout<<n<<endl;
	}
//	cout<<endl<<a<<' '<<b<<endl;
	for(int i=1;i<=a;i++) putchar('a');
	for(int i=1;i<=b;i++) putchar('b');
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<60
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int V;
ll G[20][20];  // グラフ
ll dp[200000][20];
int main() {
    cin >> V;
    // グラフの初期化
    rep(i, 20) {
        rep(j, 20) { G[i][j] = INF; }
    }

    vector<ll> x(V),y(V),z(V);
    rep(i, V) {
        cin>>x[i]>>y[i]>>z[i];
    }

    rep(i,V){
        rep(j,V){
            G[i][j]=abs(x[j]-x[i])+abs(y[j]-y[i])+max(0LL,z[j]-z[i]);
        }
    }

    // dp の初期化
    rep(i, 200000) {
        rep(j, 20) { dp[i][j] = INF; }
    }
    dp[0][0] = 0;  // スタートを頂点 0 とする
    rep(S, 1 << V) {
        rep(v, V) {
            rep(u, V) {
                if ((S & (1 << v)) == 0) {
                    if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + G[u][v]);
                }
            }
        }
    }
    if (dp[(1 << V) - 1][0] != INF) {
        cout << dp[(1 << V) - 1][0] << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a); i<(n); i++)
#define rep2(i,a,n) for (int i=(a); i<=(n); i++)
using ll = long long;
using ld = long double;
using P = pair<int,int>;
int main() {
  string s; cin >> s;
  deque<char> d;
  bool rev = false;
  rep(i,0,s.size()) {
    char c = s.at(i);
    if(c == 'R') rev = !rev;
    else {
      if(rev) d.push_front(c);
      else d.push_back(c);
    }
  }
  if(rev) reverse(d.begin(), d.end());
  string ans = "";
  rep(i,0,d.size()) {
    char c = d[i];
    if(ans.size() != 0 && ans.back() == c) ans.pop_back();
    else ans += c;
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0() {}
template<typename H,typename... T> void print0(H h,T... t){cout<<fixed<<setprecision(15)<<h;print0(t...);}
void print() { print0("\n"); }
template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void ioinit() { cout << fixed << setprecision(15); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on

void output(vector<vector<ll>> &use, vector<vector<ll>> &nouse, ll end) {
    ll n = use.size();

    ll j = end;
    vector<ll> ru;
    for (ll i = n - 1; i >= 0; i--) {
        if (use[i][j] != j) {
            ru.push_back(i);
        }
        j = use[i][j];
    }

    j = end;
    vector<ll> rn;
    for (ll i = n - 1; i >= 0; i--) {
        if (nouse[i][j] != j) {
            rn.push_back(i);
        }
        j = nouse[i][j];
    }

    reverse(ru.begin(), ru.end());
    reverse(rn.begin(), rn.end());
    print("Yes");

    print0(ru.size());
    for (ll i = 0; i < (ll)ru.size(); i++) {
        print0(" ", 1 + ru[i]);
    }
    print();

    print0(rn.size());
    for (ll i = 0; i < (ll)rn.size(); i++) {
        print0(" ", 1 + rn[i]);
    }
    print();
}

int main() {
    ioinit();
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll zero = INF;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        a[i] = a[i] % 200;
        if (a[i] == 0) {
            zero = i;
        }
    }
    if (zero != INF) {
        print("Yes");
        if (zero == n - 1) {
            print("2 1", (zero + 1));
            print("1 1");
        } else {
            print(2, (zero + 1), (zero + 2));
            print(1, (zero + 2));
        }
        return 0;
    }
    for (ll u = 0; u < n; u++) {
        vector<vector<ll>> use(n, vector<ll>(200, -1));
        vector<vector<ll>> nouse(n, vector<ll>(200, -1));
        if (u == 0) {
            use[0][a[0]] = 0;
            nouse[0][0] = 0;
        } else {
            use[0][0] = 0;
            use[0][a[0]] = 0;
            nouse[0][0] = 0;
            nouse[0][a[0]] = 0;
        }
        for (ll i = 1; i < n; i++) {
            for (ll j = 0; j < 200; j++) {
                ll nj = (j + a[i]) % 200;
                if (use[i - 1][j] >= 0) {
                    use[i][nj] = j;
                    if (u != i) use[i][j] = j;
                }
                if (nouse[i - 1][j] >= 0) {
                    if (u != i) nouse[i][nj] = j;
                    nouse[i][j] = j;
                }
            }
            for (ll j = 1; j < 200; j++) {
                if (use[n - 1][j] >= 0 && nouse[n - 1][j] >= 0) {
                    output(use, nouse, j);
                    return 0;
                }
            }
        }
    }
    print("No");
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }

template<class T> void DBG(T&& x) { cerr << x << " "; }
template<class T, class...Args> void DBG(T&& x, Args&&... args) { DBG(x); DBG(args...); }
#define DBG(...) { cerr << "[" << #__VA_ARGS__ << "]: "; DBG(__VA_ARGS__); cerr << endl; }
template<class num> inline void rd(num& x) { cin >> x; }
template <class Ty, class... Args> inline void rd(Ty& x, Args&... args) { rd(x); rd(args...); }
template<class num> inline void print(num&& x) { cout << x; }
template <class Ty, class... Args> inline void print(Ty&& x, Args&&... args) { print(x); print(' '); print(args...); }
#define print(...) print(__VA_ARGS__), print('\n')

const int MAXN = 1e5 + 5;

struct Edge {
	int v;
	ll t, k;
	Edge(int v, ll t, ll k) : v(v), t(t), k(k) {}
};
vector<Edge> edges[MAXN];

ll dist[MAXN];

ll find_next(ll cur, ll t, ll k) {
	ll next = (cur + k - 1) / k * k;
	return next + t;
}

ll dijkstra(int s, int t) {
	fill(dist, dist+MAXN, LLONG_MAX);
	dist[s] = 0;
	priority_queue<pii> pq;
	pq.emplace(0, s);
	while(pq.size()) {
		auto [d, u] = pq.top();
		pq.pop();
		if (-d > dist[u]) continue;
		for (auto e : edges[u]) if (dist[e.v] > find_next(dist[u], e.t, e.k)) {
			dist[e.v] = find_next(dist[u], e.t, e.k);
			pq.emplace(-dist[e.v], e.v);
		}
	}

	return dist[t] == LLONG_MAX ? -1 : dist[t];
}

inline void run_test(int test_number) {
	int n, m, a, b; rd(n, m, a, b);
	for (int i = 0; i < m; i++) {
		int u, v, t, k; rd(u, v, t, k);
		edges[u].emplace_back(v, t, k);
		edges[v].emplace_back(u, t, k);
	}
	print(dijkstra(a, b));
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n_tests = 1;
	for (int i = 1; i <= n_tests; i++) run_test(i);
}

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

int main(){
  int a,b,c,d;
  std::cin >> a >>b>>c>>d;
  std::cout << a*d-b*c << '\n';

  return 0;
}


#include <bits/stdc++.h>
#define przxct ""
#define fto(i,j,h)    for (int i=j; i<=h; ++i)
#define maxn
#define ll long long
#define pi 3.141592653589

using namespace std;

string x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> x;
    string rs = "";
    fto(i,0,x.length()-1)
    {
        if (x[i] == '.')    break;
        rs += x[i];
    }
    cout << rs;
    return 0;
}

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rep1(i, n) for(long long i = 1; i <= (long long)(n); i++)
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007

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; }

using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n,saidai,m;
    ll stop = 0;
    cin >> n;
    saidai = n+1;
    m = saidai/2+1;
    rep1(i,m){
        if(saidai-i>=0){
            saidai = saidai-i;
            stop++;
        }else{
            break;
        }
    }
    cout << n-stop+1;
}


#include <iostream>

int main() {
	int x, y;
	std::cin >> x >> y;

	for (int i = y; i >= 1; i--) {
		if ((x + i - 1) / i * i <= y && (x + i - 1) / i * i + i <= y) {
			std::cout << i;
			break;
		}
	}

	return 0;
}

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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T, size_t sz> ostream &operator<<(ostream &os, const array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T, typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV, typename TH> ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }

// #define DEBUG

#ifdef DEBUG
const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m", NORMAL_CROSSED = "\033[0;9;37m", RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#define dbg(x) cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << " in " << __FILE__ << ")" << COLOR_RESET << endl
#else
#define dbg(x) (x)
#endif

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

	vector<vector<bool>> mat;

	int A, B;
	cin >> A >> B;

	for (int c = B; ; c--) {
		if ((A + c - 1) / c < B / c) {
			cout << c << endl;
			return 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
  int n, k, m, i, s = 0, e, res;
  cin >> n >> k >> m;
  for (i = 0; i < n - 1; i++) {
    cin >> e;
    s += e;
  }
  res = -1;
  for (i = 0; i <= k; i++) {
  	if ((s + i) / n >= m) {
      res = i;
      break;
    }
  }
  cout << res << "\n";
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}

int main()
{
	lli n,k,m;
	cin>>n>>k>>m;
	lli avg=0;
	for(int i=1;i<n;i++)
	{lli x;
		cin>>x;
		avg+=x;}
	lli ans=n*m-avg;
	if(ans<=0)
		cout<<0;
	else if(ans<=k)
		cout<<ans;
	else
		cout<<-1;

}


/*
  Author     : MatsuTaku
  Date         : 04/24/21
  Certificate:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDF9T447OEo8XSQ6O1AznN5tKC8mzvYc4Zs3+oOKfMqgLXfOwQnpfcoxKs4MAP1eICBD13PkcIezJ9IlV6nKQZKs1BQmvjSXJ+zKK8YCKvAueNPuNO0Bim43IBaNHNFWcMvcmUvHgRb6hUSO0V8I7OsjiFo20KDBj3gAznu9tir0Q== CompetitiveProgrammingCertification:tkm.matsumoto@gmail.com
*/

#include <bits/stdc++.h>
using namespace std;
#include <x86intrin.h>
#define REP(i, l, r)      for (int i = (l), i##_less = (r); i < i##_less; i++)
#define rep(i, n)         REP(i, 0, n)
#define RREP(i, l, r)     for (int i = (r)-1, i##_least = (l); i >= i##_least; i--)
#define rrep(i, n)        RREP(i, 0, n)
#define chmax(dst, x)     dst = max(dst, (x))
#define chmin(dst, x)     dst = min(dst, (x))
using lint = long long int;
using ulint = unsigned long long int;
template<typename T>
using vvec = vector<vector<T>>;
template<typename T>
vvec<T> make_vvec(int n, int m, T v) { return vvec<T>(n, vector<T>(m, v)); }

class Solver {
 public:
  Solver();
  void solve();
};

Solver::Solver() {}

void Solver::solve() {
  int n,m; cin>>n>>m;
  vector<tuple<int,int,int>> R(m);
  vector<vector<int>> I(n+1);
  rep(i, 1<<n) {
    I[__builtin_popcount(i)].push_back(i);
  }
  rep(i, m) {
    int x,y,z; cin>>x>>y>>z;
    R[i] = {x,y,z};
  }
  sort(R.begin(), R.end());
  vector<lint> dp(1<<n), old;
  dp[0] = 1;
  int k = 0;
  REP(i, 1, n+1) {
    old.assign(1<<n, 0);
    swap(dp, old);
    int t = k;
    while (t < m and get<0>(R[t]) == i) t++;
    for (auto u : I[i-1]) {
//      cerr<<bitset<18>(u)<<' '<<dp[u]<<endl;
      rep(j,  n) {
        if ((u & (1<<j)) != 0) continue;
        auto v = u | (1<<j);
        bool ok = true;
        REP(l, k, t) {
          auto [x,y,z] = R[l];
          auto vcnt = __builtin_popcount(v % (1<<y));
          ok &= vcnt <= z;
        }
        if (ok)
          dp[v] += old[u];
      }
    }
    k = t;
  }
  cout << dp[(1<<n)-1] << endl;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  Solver solver;
  int t = 1;
//  cin>>t;
  while (t--) {
    solver.solve();
  }
  return 0;
}

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main() {
    int N; ll C;
    cin >> N >> C;
    map<int,ll> mp;

    REP(i,N) {
        int a,b; cin >> a >> b;
        ll c; cin >> c;
        mp[a] += c;
        mp[b+1] -= c;
    }

    ll ans = 0;
    int p = 0;ll now = 0;

    for(auto x : mp) {
        ans += (x.first-p) * min(C,now);
        p = x.first;
        now += x.second;
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#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 pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int maxn=500;
ll a[maxn+5][maxn+5];
int main()
{

    int n;
    cin>>n;
    rep(i,0,n)
    {
        rep(j,0,n)
        cin>>a[i][j];
    }
    bool flag=1;
    ll dif[n];
    rep(i,0,n)
    {
        dif[i]=a[i][0]-a[(i+1)%n][0];
    }
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            ll tmp=a[i][j]-a[(i+1)%n][j];
            if(tmp!=dif[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    rep(i,0,n)
    {
        dif[i]=a[0][i]-a[0][(i+1)%n];
    }
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            ll tmp=a[j][i]-a[j][(i+1)%n];
            if(tmp!=dif[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    ll min=0x3f3f3f3f3f3f3f3f;
    int minum=0;
    ll ans1[maxn+5];
    ll ans2[maxn+5];
    rep(i,0,n)
    {
        if(a[i][0]<min)
        {
            minum=i;
            min=a[i][0];
        }
    }
    rep(i,0,n)
    {
        ans2[i]=a[minum][i];
    }
    rep(i,0,n)
    {
        ans1[i]=a[i][0]-ans2[0];
    }
    rep(i,0,n)
    {
        cout<<ans1[i]<<" ";

    }
    cout<<endl;
    rep(i,0,n)
    {
        cout<<ans2[i]<<" ";
    }
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a == b + c + d) {
		cout << "Yes";
	} else if (b == a + c + d) {
		cout << "Yes";
	} else if (c == a + b + d) {
		cout << "Yes";
	} else if (d == a + b + c) {
		cout << "Yes";
	} else if ((a + b) == (c + d)) {
		cout << "Yes";
	} else if ((a + c) == (b + d)) {
		cout << "Yes";
	} else if ((a + d) == (b + c)) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


#include<iostream>
using namespace std;
using ll = long long;

ll sum_comb(ll n) {
  if (n <= 2) return 0;
  return (n - 1) * (n - 2) / 2;
}

ll sum_comb2(ll n, ll N) {
  return (sum_comb(n) - sum_comb(n - 3 * N)) - 3 * (sum_comb(n - N) - sum_comb(n - 2 * N));
}

int main() {
  int N; ll K;
  cin >> N >> K;
  ll cnt = 0; int sum = 3;
  while (true) {
    cnt += sum_comb2(sum, N);
    if (cnt >= K) break;
    sum++;
  }
  cnt -= sum_comb2(sum, N);

  int i = 1;
  while (true) {
    cnt += max(0, min(sum - i - 1, 2 * N - sum + i + 1));
    if (cnt >= K) break;
    i++;
  }
  cnt -= min(sum - i - 1, 2 * N - sum + i + 1);

  int j = K - cnt + max(0, sum - i - N - 1);
  int k = sum - i - j;

  cout << i << " " << j << " " << k << endl;
}

#include<bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#define ri register signed
#define rd(x) x=read()
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N=3e6+5;
const int M=31;
const int mod=1e9+7;
inline int read(){int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline int ksm(int x,int y=mod-2,int z=mod){int ret=1;while (y){if (y&1) ret=(ret*x)%z;x=(x*x)%z;y>>=1;}return ret;}
int inv[N],fac[N],ifc[N];
void Init(int n)
{
    inv[1]=1;for (ri i=2;i<=n;i++)inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    fac[0]=1;for (ri i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
    ifc[0]=1;for (ri i=1;i<=n;i++) ifc[i]=ifc[i-1]*inv[i]%mod;
}
int C(int n,int m){if (m>n || m<0) return 0;return fac[n]*ifc[m]%mod*ifc[n-m]%mod;}
int n,m,ans,tot,tmp,K,a,b,c;
int cnt1[N],cnt2[N],cnt3[N];
signed main()
{
    rd(n);rd(K);
    //a+b+c=i
    //a=j
    //b+c=i-j
    //2->1 1
    //1 1 1
    //1 1 2 1 2 1 1 2 2
    //
    for (int i=1;i<=n;i++) cnt1[i]=1;
    tot=0;
    for (int i=1;i<=2*n;i++)
    {
        cnt2[i]+=tot;
        if (i<=n) tot+=cnt1[i];
        else tot+=cnt1[i],tot-=cnt1[i-n];
    }
    for (int i=1;i<=3*n;i++)
    {
        cnt3[i]+=tot;
        if (i<=n) tot+=cnt2[i];
        else tot+=cnt2[i],tot-=cnt2[i-n];
    }
    //for (int i=1;i<=3*n;i++) printf("cnt[%lld]=%lld\n",i,cnt3[i]);
    for (int i=3;i<=3*n;i++)
    {
        tmp=cnt3[i];
        //n 以内选 3 个数之和为 x 的方案数
        //
        tot+=tmp;
        if (tot>=K)
        {
            tot-=tmp;
            for (int j=1;j<=i-2;j++)
            {
                tmp=cnt2[i-j];
                tot+=tmp;
                if (tot>=K)
                {
                    a=j;
                    tot-=tmp;
                    for (int k=1;k<=i-j;k++)
                    {
                        b=k;
                        c=i-a-b;
                        if (c<=n) tot++;
                        if (tot==K){ cout<<a<<" "<<b<<" "<<c<<endl;return 0;}
                    }

                }
            }
        }
    }
}


#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second

#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;

    cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        ll cnt =0 ;
        while(n % 2 == 0){
            n /= 2;
            cnt++;
        }
        if(cnt == 1){
            cout << "Same\n";
        }
        else if(cnt == 0){
            cout << "Odd\n";
        }
        else{
            cout << "Even\n";
        }
    }
    return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
//#define MOD 998244353
#define EPS 0.000000001
using namespace std;

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

//中国剰余定理(vec_val: 合同式の右辺集合 vec_m:合同式のmodの集合)
//https://qiita.com/drken/items/ae02240cd1f8edfc86fd
pair<ll,ll> ChineseRem(const vector<ll>&vec_val,const vector<ll>&vec_m){

	if(vec_val.empty()||vec_m.empty())return make_pair(0,1);

	ll VAL = vec_val[0];
	ll M = vec_m[0];

	ll x,y,val,m;

	for (int i = 1; i < (int)vec_val.size(); i++) {

		val = vec_val[i], m = vec_m[i];

		if (M < m){
			swap(M, m);
			swap(VAL,val);
		}

		//Mx + my = gcd(M,m)(→d)
		ll d = extgcd(M,m,x,y); //d: Mとmのgcd

		/*
		 * 解の存在条件
		 * VAL≡val(mod d[=gcd(M,m)])より、
		 * val-VAL≡0 (mod d)
		 *
		 *
		 * */
		if ((val-VAL)%d != 0){ //解の存在条件を満たさないので不適

			return make_pair(0, -1);
		}

		ll md = m/d; //d = gcd(M,m)なので、mはdで割れる
		ll tmp = ((val- VAL)/d) % md * x % md;

		VAL += M*tmp;
		M *= md; //法→lcm(m1,m2,m3...)[前の法Mと今回の法mをかけてからgcd(M,m)で割るのと同じ→lcm演算と同じ]
	}

	VAL %= M;
	if (VAL < 0){
		VAL += M;
	}
	return make_pair(VAL, M);
}

void func(){

	ll X,Y,P,Q;
	scanf("%lld %lld %lld %lld",&X,&Y,&P,&Q);

	ll ans = HUGE_NUM;

	for(ll a = X; a < X+Y; a++){
		for(ll b = P; b < P+Q; b++){

			pair<ll,ll> tmp_p = ChineseRem({a,b},{2*(X+Y),(P+Q)});
			if(tmp_p.second == -1)continue;

			ans = min(ans,tmp_p.first);

		}
	}

	if(ans == HUGE_NUM){

		printf("infinity\n");
	}else{

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

int main(){

	int num_case;
	scanf("%d",&num_case);

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

		func();
	}

	return 0;
}


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

int maxof(int x, int y)
{
    if (x > y)
        return x;
    else
        return y;
}

int main()
{
    int n;
    int a[1000], b[1000];
    int ans;

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

    int a_id[1000], b_id[1000];
    int a_min = a[0];
    int b_min = b[0];
    int counta = 0, countb = 0;

    for (int i = 1; i < n; i++)
    {
        if (a_min > a[i])
            a_min = a[i];

        if (b_min > b[i])
            b_min = b[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] == a_min)
        {
            a_id[counta] = i;
            counta++;
        }

        if (b[i] == b_min)
        {
            b_id[countb] = i;
            countb++;
        }
    }

    sort(a, a + n);
    sort(b, b + n);

    int a_min2 = a[1];
    int b_min2 = b[1];

    int w = 0;

    for (int i = 0; i < counta; i++)
        for (int j = 0; j < countb; j++)
        {
            if (a_id[i] == b_id[j])
                w = 1;
        }

    if (w != 1)
    {
        if (a_min > b_min)
            ans = a_min;
        else
            ans = b_min;
    }
    else
    {
        if (a_min + b_min < a_min2 && a_min + b_min < b_min2)
        {
            ans = a_min + b_min;
        }
        else
        {
            if (maxof(a_min, b_min2) < maxof(a_min2, b_min))
                ans = maxof(a_min, b_min2);
            else
                ans = maxof(a_min2, b_min);
        }
    }

    cout << ans << endl;

    return 0;
}

#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;++i)
#define _rep(i,s,t) for(int i=s;i>=t;--i)
#define Rep(i,s,t) for(int i=s;i<t;++i)
#define go(x) for(int e=las[x];e;e=nxt[e])
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define _open(x) freopen(#x".in","w",stdout)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define Rd rand()<<15|rand()
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
using namespace std;
const int N=1e6+11;
int a[N],b[N];
int A,B;
int n;
int main(){
	gi(n);
	rep(i,1,n)
		gi(a[i]);
	rep(i,1,n)
		gi(b[i]);
	long long ans=0;
	rep(i,1,n){
		A=max(A,a[i]);
		B=max(B,b[i]);
		ans=max(ans,1ll*b[i]*A);
		printf("%lld\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl
#define int long long

using namespace std;
typedef long long LL;

const int MAXN = 2E5 + 5;
const int MOD = 1E9 + 7;
int n, m, a[MAXN];
vector<int> delta;

template <class T>
void read(T& x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

template <class T, class... Args>
void read(T& x, Args&... args) {
    read(x), read(args...);
}

template <class T>
void write(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

signed main() {
    // freopen("1.in", "r", stdin);
    read(n, m);
    for (int i = 1; i <= m; i++) read(a[i]);
    sort(a + 1, a + m + 1);
    if (!m) {
        cout << 1;
        return 0;
    }
    a[0] = 0, a[m + 1] = n + 1;
    int ans = 0;
    for (int i = 1; i <= m + 1; i++)
        if (a[i] - a[i - 1] - 1 > 0) delta.push_back(a[i] - a[i - 1] - 1);
    // for (auto& d : delta) cout << d << endl;
    if (delta.size()) {
        int cur = 0;
        int mi = delta[0];
        for (int i = 1; i < delta.size(); i++) mi = min(mi, delta[i]);
        for (auto& now : delta) cur += ceil(1.0 * now / mi);
        ans = cur;
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265358979323846264338327950L

string randStr(){
    string ret;
    int rnd=rand()%9;
    if(rnd==8){
        ret='.';
    }else{
        ret = rnd+'A';
    }

    return ret;
}

int main(void){

    int N,M;

    cin>>N>>M;
    vector<string> S(M);
    vector<string> ans(N);

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

    int index=0;
    for(int i=0;i<N;i++){
        // if(ans[index].size()<N){
        //     ans[index].append(S[i]);
        // }else{
        //     index++;
        // }
        ans[i%N].append(S[i]);
    }

    for(int i=0;i<N;i++){
        if(ans[i].size()>N){
            ans[i] = ans[i].substr(0,N);
        }else{
            int tmp = N-ans[i].size();
            for(int j=0;j<tmp;j++){
                ans[i].append(randStr() );
            }
        }
    }

    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define N 111
#define NN 131000
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
int n, K, P;
int ans[N], lmt[N];
int f[2][NN], g[2][NN], sum[NN];
inline void Try(int mid) {
	memset(f, 0, sizeof(f));
	memset(g, 0, sizeof(g));
	memset(sum, 0, sizeof(sum));
	int up = min(lmt[mid - 1], lmt[n - mid]);
	int nw = 0; f[nw][0] = 1;
	for (int i = 1; i < mid; ++i) {
		nw ^= 1;
		int d = mid - i;
		for (int j = 0; j <= up; ++j) {
			if (j - d >= 0)	sum[j] = (sum[j - d] + f[nw ^ 1][j]) % P;
			else	sum[j] = f[nw ^ 1][j];
		}
		for (int j = 0; j <= up; ++j) {
			if (j - (K+1) * d < 0)	f[nw][j] = sum[j];
			else	f[nw][j] = (sum[j] - sum[j - (K+1) * d] + P) % P;
		}
	}
	if (nw)	memcpy(f[0], f[1], sizeof(f[1]));
	nw = 0; g[nw][0] = 1;
	for (int i = mid + 1; i <= n; ++i) {
		nw ^= 1;
		int d = i - mid;
		for (int j = 0; j <= up; ++j) {
			if (j - d >= 0)	sum[j] = (sum[j - d] + g[nw ^ 1][j]) % P;
			else	sum[j] = g[nw ^ 1][j];
		}
		for (int j = 0; j <= up; ++j) {
			if (j - (K+1) * d < 0)	g[nw][j] = sum[j];
			else	g[nw][j] = (sum[j] - sum[j - (K+1) * d] + P) % P;
		}
	}
	if (nw)	memcpy(g[0], g[1], sizeof(g[1]));
	for (int j = 0; j <= up; ++j) if (f[0][j] && g[0][j]) {
		ans[mid] = (ans[mid] + 1ll * f[0][j] * g[0][j] % P * (K + 1)) % P;
	}
}
int main() {
	read(n), read(K), read(P);
	for (int i = 1; i <= n; ++i)	lmt[i] = lmt[i - 1] + K * i;
	for (int i = 1; i <= (n + 1) >> 1; ++i)	Try(i);
	for (int i = 1; i <= n; ++i) if (!ans[i])	ans[i] = ans[n - i + 1];
	for (int i= 1; i <= n; ++i) {
		printf("%d\n", ((ans[i] - 1 + P) % P + P) % P);
	}
	return 0;
}

/*
3 1 998244353
//1 3 1

10 8 861271909

100 100 7
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

int MOD;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}

const int N = 101;
const int M = 550000;
int dp[N][M];
int n, k;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d%d%d", &n, &k, &MOD);
	dp[0][0] = 1;
	for (int x = 1; x < n; x++) {
		for (int r = 0; r < x; r++) {
			int sum = 0;
			for (int y = r; y < M; y += x) {
				sum = add(sum, dp[x - 1][y]);
				if (y >= (k + 1) * x)
					sum = sub(sum, dp[x - 1][y - (k + 1) * x]);
				dp[x][y] = sum;
			}
		}
	}

	for (int x = 1; x <= n; x++) {
		int ans = 0;
		for (int y = 0; y < M; y++) {
			ans = add(ans, mult(dp[x - 1][y], dp[n - x][y]));
		}
		ans = mult(ans, k + 1);
		ans = sub(ans, 1);
		printf("%d\n", ans);
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define Endl endl
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18

using namespace std;

typedef long long llint;
typedef pair<llint, llint> P;

llint n;
vector<int> G[105];
bool used[105];

llint dfs(int v)
{
	used[v] = true;
	llint ret = 1;
	for(auto u : G[v]){
		if(!used[u]) ret += dfs(u);
	}
	return ret;
}

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

	cin >> n;

	char c;
	rep(i, 1, n){
		rep(j, 1, n){
			cin >> c;
			if(c%2) G[j].push_back(i);
		}
	}

	double ans = 0;
	rep(i, 1, n){
		rep(j, 1, n) used[j] = false;
		ans += 1.0 / dfs(i);
	}
	printf("%.11f\n", ans);

	return 0;
}

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);
  int N;
  cin >> N;

  vector<vector<int>> r(N, vector<int>(N, 0));
  for (int i = 0; i < N; ++i) {
    string A;
    cin >> A;
    for (int j = 0; j < N; ++j)
      if (A[j] == '1') r[i][j] = 1;
    r[i][i] = 1;
  }

  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        r[i][j] |= r[i][k] & r[k][j];
      }
    }
  }

  double ret = 0;
  for (int i = 0; i < N; ++i) {
    int cnt = 0;
    for (int j = 0; j < N; ++j) cnt += r[j][i];
    ret += 1.0 / cnt;
  }

  cout << std::setprecision(15) << ret << '\n';
  return 0;
}


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

template <typename T>
int len(const T& a) {
	return a.size();
}
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int i = -400000; i <= 400000; ++i) {
		if (abs(k - i) > n - 1 || abs(i) > n - 1)
			continue;
		ans += 1ll * abs(n - abs(i)) * abs(n - abs(k - i));
	}
	cout << ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const
#define fr first
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])

cs int G = 3;
cs int ff = 1e6 + 15;
cs int inf = 1e18 + 1;
cs int base = 4;
cs int M = 998244353;

void Add(int &x, int y) { x = (x + y) % M; if(x < 0) x += M; }

int ksm(int x, int y) { return (y % 2 == 1 ? x : 1) * (y ? ksm(x * x % M, y >> 1) : 1) % M; }

int n, k;
int calc(int x)
{
	if(x <= 0 || x > n + n) return 0;
	if(x <= n) return x - 1;
	return n + n + 1 - x;
}
void init()
{
	cin >> n >> k; int Ans = 0;
	rep(i, 1, n + n + n) Ans = Ans + calc(i) * calc(i - k);
	cout << Ans;
}
signed main()
{
//	freopen("triad.in", "r", stdin);
//	freopen("triad.out", "w", stdout);
	int Ts = 1;
	while(Ts--)
		init();

}
/*

*/


#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005;
int n,m,Q;
int a[N],b[N];
struct Segment_Tree
{
	struct Node
	{
		int ls,rs;
		int cnt;
		long long sum;
	}tree[N*20];
	int rt,tot;
	void modifycnt(int &i,int l,int r,int pos,int val)
	{
		if(!i) i=++tot;
		if(l==r)
		{
			tree[i].cnt+=val;
			return;
		}
		int mid=(l+r)/2;
		if(pos<=mid) modifycnt(tree[i].ls,l,mid,pos,val);
		else modifycnt(tree[i].rs,mid+1,r,pos,val);
		tree[i].cnt=tree[tree[i].ls].cnt+tree[tree[i].rs].cnt;
		return;
	}
	void modifysum(int &i,int l,int r,int pos,int val)
	{
		if(!i) i=++tot;
		if(l==r)
		{
			tree[i].sum+=val;
			return;
		}
		int mid=(l+r)/2;
		if(pos<=mid) modifysum(tree[i].ls,l,mid,pos,val);
		else modifysum(tree[i].rs,mid+1,r,pos,val);
		tree[i].sum=tree[tree[i].ls].sum+tree[tree[i].rs].sum;
		return;
	}
	int querycnt(int i,int l,int r,int L,int R)
	{
		if(!i) return 0;
		if(L<=l&&r<=R) return tree[i].cnt;
		int mid=(l+r)/2;
		int res=0;
		if(L<=r) res+=querycnt(tree[i].ls,l,mid,L,R);
		if(R>=l) res+=querycnt(tree[i].rs,mid+1,r,L,R);
		return res;
	}
	long long querysum(int i,int l,int r,int L,int R)
	{
		if(!i) return 0;
		if(L<=l&&r<=R) return tree[i].sum;
		int mid=(l+r)/2;
		long long res=0;
		if(L<=r) res+=querysum(tree[i].ls,l,mid,L,R);
		if(R>=l) res+=querysum(tree[i].rs,mid+1,r,L,R);
		return res;
	}
}TA,TB;
int main()
{
	scanf("%d%d%d",&n,&m,&Q);
	TA.modifycnt(TA.rt,1,1e8,0,n);
	TB.modifycnt(TB.rt,1,1e8,0,m);
	long long ans=0;
	while(Q--)
	{
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t==1)
		{
			TA.modifycnt(TA.rt,1,1e8,a[x],-1);
			TA.modifysum(TA.rt,1,1e8,a[x],-a[x]);
			TA.modifycnt(TA.rt,1,1e8,y,1);
			TA.modifysum(TA.rt,1,1e8,y,y);
			ans-=1LL*TB.querycnt(TB.rt,1,1e8,1,a[x])*a[x]+TB.querysum(TB.rt,1,1e8,a[x]+1,1e8);
			ans+=1LL*TB.querycnt(TB.rt,1,1e8,1,y)*y+TB.querysum(TB.rt,1,1e8,y+1,1e8);
			a[x]=y;
		}
		else if(t==2)
		{
			TB.modifycnt(TB.rt,1,1e8,b[x],-1);
			TB.modifysum(TB.rt,1,1e8,b[x],-b[x]);
			TB.modifycnt(TB.rt,1,1e8,y,1);
			TB.modifysum(TB.rt,1,1e8,y,y);
//			cerr<<"del"<<ans<<" "<<1LL*TA.querycnt(TA.rt,1,1e8,1,b[x])*b[x]-TA.querysum(TA.rt,1,1e8,b[x]+1,1e8)<<" "<<1LL*TA.querycnt(TA.rt,1,1e8,1,y)*y-TA.querysum(TA.rt,1,1e8,y+1,1e8)<<"\n";
			ans-=1LL*TA.querycnt(TA.rt,1,1e8,1,b[x])*b[x]+TA.querysum(TA.rt,1,1e8,b[x]+1,1e8);
			ans+=1LL*TA.querycnt(TA.rt,1,1e8,1,y)*y+TA.querysum(TA.rt,1,1e8,y+1,1e8);
			b[x]=y;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <tuple>

template <class E> struct FenwickTree {
    int _n;
    std::vector<E> data;

    FenwickTree(int n) : _n(n), data(n) { }

    void add(int p, E x) {
        ++p;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }
    E sum(int r) const {
        E s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
    E sum(int l, int r) const {
        return sum(r) - sum(l);
    }
};

long long proc(
    std::vector<int>             &cur,
    int                          x,
    int                          y,
    FenwickTree<int>             &ftcnt0,
    FenwickTree<long long>       &ftsum0,
    const FenwickTree<int>       &ftcnt1,
    const FenwickTree<long long> &ftsum1,
    const std::vector<int>       &arr)
{
    int v = cur[x];
    long long dem = (long long)ftcnt1.sum(0, v) * arr[v];
    long long cre = (long long)ftcnt1.sum(0, y) * arr[y];
    long long adj = (long long)ftsum1.sum(y, v);

    ftsum0.add(v, -arr[v]);
    ftcnt0.add(v, -1);
    cur[x] = y;
    ftsum0.add(y, arr[y]);
    ftcnt0.add(y, 1);

    return cre + adj - dem;
}

int main(int argc, char **argv)
{
    int n, m, q;
    std::cin >> n >> m >> q;
    std::vector<std::tuple<int, int, int>> txy;
    std::set<int> s = { 0 };

    for (int i = 0; i < q; i++) {
        int t, x, y;
        std::cin >> t >> x >> y;
        txy.push_back(std::make_tuple(t, x - 1, y));
        s.insert(y);
    }
    std::vector<int> arr(s.begin(), s.end());
    std::map<int, int> map;
    int ll = s.size();

    for (int i = 0; i < ll; i++) map.emplace(arr[i], i);

    FenwickTree<long long> ftsuma(ll);
    FenwickTree<long long> ftsumb(ll);
    FenwickTree<int>       ftcnta(ll);
    FenwickTree<int>       ftcntb(ll);
    std::vector<int> cura(n);
    std::vector<int> curb(m);
    ftcnta.add(0, n);
    ftcntb.add(0, m);
    long long sum = 0;

    for (const auto&e : txy) {
        int cy = map[std::get<2>(e)];
        sum += (std::get<0>(e) == 1) ? proc(cura, std::get<1>(e), cy, ftcnta, ftsuma, ftcntb, ftsumb, arr)
                                     : proc(curb, std::get<1>(e), cy, ftcntb, ftsumb, ftcnta, ftsuma, arr);
        std::cout << sum << std::endl;
    }
    return 0;
}


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

ll func(ll i) {
    ll refact;
    string i_st = to_string(i);
    i_st += i_st;
    refact = stoll(i_st);
    return refact;
}
int main() {
    ll N;
    cin >> N;
    int i = 1;
    int ans = 0;
    while(func(i) <= N) {
        ans++;
        i++;
    }
    cout << ans << endl;

}


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

ll n, f[1005];
int flg[1005];
vector<int> vec;

#define pb push_back

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w;
}

int main()
{
#ifndef ONLINE_JUDGE
	//freopen("cpp.in", "r", stdin);
#endif
	n = read <ll> ();
	f[0] = 0, f[1] = 1;
	for(int i = 2; i <= 88; i++) f[i] = f[i - 1] + f[i - 2];
	ll tmp = n; int pos = 0;
	for(int i = 87; i >= 1; i--) if(tmp >= f[i]) flg[i] = 1, tmp -= f[i];
	for(int i = 1; i <= 87; i++) if(flg[i]) pos = i;
	for(int i = pos, j = 1; i >= 1; j++, i--)
	{
		if(flg[i])
		{
			if(i & 1) vec.pb(1);
			else vec.pb(2);
		}
		if(j & 1) vec.pb(4);
		else vec.pb(3);
	}
	printf("%lu\n", vec.size());
	for(auto i : vec) printf("%d\n", i);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
const int MAXN = 100005;
const ll MOD = 1e9+7;

ll fib[MAXN];
int cnt[MAXN];

inline void solve()
{
	ll n;	cin >> n;
	fib[1] = 1;
	int tk = 0;
	for (int i=2;;i++)
	{
		fib[i] = fib[i-1] + fib[i-2];
		if (fib[i] > n)
		{
			tk = i - 1;
			break;
		}
	}

//	cout << tk << ": " << fib[tk] << "\n";
	int len = tk;

	ll sum = n - fib[tk];
	while (sum)
	{
		int id = upper_bound(fib+1,fib+tk+1,sum) - fib - 1;
		int t = tk - id + 1;
		cnt[t]++;
		len++;
		sum -= fib[id];
	}
	cout << len << "\n";

	int l = 3,r = 4;

	if (tk%2==0)
		swap(l,r);

	for (int i=1;i<=tk;i++)
	{
		if (i&1)
		{
			if (i == 1)
			{
				if (tk&1)
					cout << 1 << "\n";
				else
					cout << 2 << "\n";
			}
			else
			{
				cout << l << "\n";
				for (int j=1;j<=cnt[i];j++)
					cout << ( (tk&1) ? 1 : 2 ) << "\n";
			}
		}
		else
		{
			cout << r << "\n";
			for (int j=1;j<=cnt[i];j++)
				cout << ( (tk&1) ? 2 : 1 ) << "\n";
		}
	}

}

int main()
{
	solve();
	return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int mod = 3;
int sum(int a, int b){return (a+b) % mod;}
int sub(int a, int b){return (a + mod - b) % mod;}
int mul(int a, int b){return (1ll * a * b) % mod;}
int power(int a,int b){
	int res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}
const int maxn = 400010;
int fac[maxn],caf[maxn],pot[maxn];
int deg(int x,int d){
	d %= mod - 1;
    if(d < 0)d += mod - 1;
    int y = 1;
    while(d){
		if (d & 1)y = mul(y,x);
        x = mul(x,x);
        d /= 2;
    }
    return y;
}
int coeff(int n,int k){
	return mul(fac[n],mul(caf[k],caf[n-k]));
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	fac[0] = caf[0] = 1;
	forn(i,1,maxn){
		int act = i;
		int add = 0;
		while(act%3 == 0){
			act /= 3;
			add++;
		}
		fac[i] = mul(act,fac[i-1]);
		pot[i] = add+pot[i-1];
		caf[i] = deg(fac[i],-1);
	}
	//forn(i,1,10){
		//debug(i,fac[i],caf[i],pot[i]);
	//}
	int N; cin >> N;
	string str; cin >> str;
	map<char,int> val = {{'B',0},{'W',1},{'R',2}};
	map<int,char> rev = {{0,'B'},{1,'W'},{2,'R'}};
	int act = 0;
	int sig = (N%2 == 0) ? -1 : 1;
	forn(i,0,N){
		if(i == 0 || i == N-1){
			act = sum(act,mul(sig,val[str[i]]));
		}else{
			int p1 = pot[N-1];
			int p2 = pot[i]+pot[N-1-i];
			int p = p1-p2;
			int add = mul(mul(coeff(N-1,i),val[str[i]]),sig);
			if(p >= 0){
				add = mul(add,power(3,p));
			}else{
				add = power(3,p);
			}
			act = sum(act,add);
			//debug(N-1,i,coeff(N-1,i),add,p);
		}
	}
	if(act < 0)act += mod;
	cout << rev[act] << '\n';

	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define forn(i,x,n) for(ll i=x;i<n;i++)
#define pb push_back
#define int             long long
#define mp make_pair
#define debug(x) cout<<x<<"\n";
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define endl '\n'
#define N 1000000
int n,m,k,b,c,d,x,y,z,e,v,r,w,f;
string s;
int a[1000000];
void least_prime_factor(vector<int>&lpf,vector<int>&mobius)
{
    for (int i = 2; i < 2000000; i++)

        // If it is a prime number
        if (!lpf[i])

            for (int j = i; j < 2000000; j += i)

                // For all multiples which are not
                // visited yet.
                if (!lpf[j])
                    lpf[j] = i;
}

// Function to find the value of Mobius function
// for all the numbers from 1 to n
void Mobius(vector<int>&lpf,vector<int>&mobius)
{
    for (int i = 1; i < 2000000; i++) {

        // If number is one
        if (i == 1)
            mobius[i] = 1;
        else {

            // If number has a squared prime factor
            if (lpf[i / lpf[i]] == lpf[i])
                mobius[i] = 0;

            // Multiply -1 with the previous number
            else
                mobius[i] = -1 * mobius[i / lpf[i]];
        }
    }
}

// Function to find the number of pairs
// such that gcd equals to 1
int gcd_pairs(vector<int>&a, int n,vector<int>&lpf,vector<int>&mobius)
{
    // To store maximum number
    int maxi = 0;

    // To store frequency of each number
    vector<int>fre(2000000,0);

    // Find frequency and maximum number
    for (int i = 0; i < n; i++) {
        fre[a[i]]++;
        maxi = max(a[i], maxi);
    }

    least_prime_factor(lpf,mobius);
    Mobius(lpf,mobius);

    // To store number of pairs with gcd equals to 1
    int ans = 0;

    // Traverse through the all possible elements
    for (int i = 1; i <= maxi; i++) {
        if (!mobius[i])
            continue;

        int temp = 0;
        for (int j = i; j <= maxi; j += i)
            temp += fre[j];

        ans += temp * (temp - 1) / 2 * mobius[i];
    }

    // Return the number of pairs
    return ans;
}

// Driver code
int32_t main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   //std::cout << fixed<< std::setprecision(3);

   int  t;
    t=1;
    //cin>>t;
    while(t--)
    {
     cin>>x>>y;
    vector<int>a(y-x+1);
    vector<int>lpf(2000000,0);
    vector<int>mobius(2000000,0);

    int j=0;
    for(int i=x;i<=y;i++)
    {
    	 a[j++]=i;
	}
    int n =y-x+1;

    // Function call
    int ah=n-1;
    int ans=((ah)*(ah+1))/2;
   int temp= gcd_pairs(a, n,lpf,mobius);
    ans-=temp;
    if(x==1)
     x++;
	  for(int i=x;i<=y;i++)
	  {
	      int l=i;
	      j=2;
	  	 while((i*j)<=y)
	  	 {
	  	 	 j++;
	  	 	 ans--;
		   }
	  }
	  ans=ans*2;
	  cout<<ans<<endl;

  }

}


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

int main(){
  long long int n;
  cin>>n;
  long long x=sqrt(n+1);

  long long total=(x*(x+1))/2;
  x++;
  while(total<=n+1){
    total+=x;
    x++;
  }
  total-=x;
  x-=2;
  cout<<1+(n-x)<<endl;
}

#include <iostream>
using namespace std;
int main()
{
    long long k;
    cin>>k;
    long long i,j;
    long long b,c;
    long long cnt=0;
    for(i=1;i<=k;i++){
        b=k/i;
        if(b<i) break;
        for(j=i;j<=k;j++){
            c=k/(i*j);
            if(c<j) break;
            if(i==j){
                cnt+=1;
                cnt+=(c-j)*3;
            }else{
                cnt+=3;
                cnt+=(c-j)*6;
            }
        }
        if(c<j) continue;
    }
    cout<<cnt<<endl;
    return 0;
}


/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;
template<class T>void show(vector<T> &a) {cerr << "[ "; for (int ij = 0; ij < (int)a.size(); ij++) {cerr << a[ij] << " ";} cerr << "]\n";}
template<class T>void show(T a) {cerr << a << endl;}
template<typename... T>void show(T... args) {((cerr << args << ' '), ...); cerr << endl;}
template<class T>void read(vector<T> &a) {for (auto &x : a) {cin >> x;}}
template<class T> void read(T &a) {cin >> a;}

void solve() {
	int i, j;
	int x, y;

	cin >> x >> y;

	if (x > y)swap(x, y);

	if (x == 0 && y == 1) {
		cout << 2 << endl;
	}
	else if (x == 1 && y == 2) {
		cout << 0 << endl;
	}
	else if (x == 0 && y == 2) {
		cout << 1 << endl;
	}
	else {
		cout << x << endl;
	}

}

int32_t main(int32_t argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int T = 1;
	// cin >> T;
	while (T--) {
		solve();
	}
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
const int Maxn=2010;
const int INF=0x3f3f3f3f;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
typedef pair<int,int> pii;
vector<int>from[Maxn*Maxn];
char s[Maxn][Maxn];
int dist[Maxn*Maxn];
int st,ed;

void dij(){
	memset(dist,INF,sizeof(dist));
	priority_queue<pii>q;
	dist[st]=0;
	q.push(make_pair(0,st));
	while(!q.empty()){
		int u=q.top().second;
		int d=-q.top().first;
		q.pop();
		if(d>dist[u])continue;
		for(int i=0;i<(int)from[u].size();i++){
			int to=from[u][i];
			int cost=d;
			if(u<n*m)cost++;
			if(dist[to]>cost){
				dist[to]=cost;
				q.push(make_pair(-cost,to));
			}
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
		for(int j=0;j<m;j++){
			if(s[i][j]=='S')st=i*m+j;
			if(s[i][j]=='G')ed=i*m+j;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)if(s[i][j]!='#'){
			for(int d=0;d<4;d++){
				int nx=i+dx[d];
				int ny=j+dy[d];
				if(nx>=0&&nx<n&&ny>=0&&ny<m&&s[nx][ny]!='#'){
					from[i*m+j].push_back(nx*m+ny);
				}
			}
			if(s[i][j]>='a'&&s[i][j]<='z'){
				from[i*m+j].push_back(n*m+s[i][j]-'a');
				from[n*m+s[i][j]-'a'].push_back(i*m+j);
			}
		}
	}
	dij();
	if(dist[ed]==INF)printf("-1\n");
	else printf("%d\n",dist[ed]);
	return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define li long long
#define pii pair<int, int>
#define vi vector<int>
#define li long long

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

const int MAXN = 505;

int c[MAXN][MAXN];

int main() {
	int n;
	scanf("%d", &n);
	forn(i, n) {
		forn(j, n) {
			scanf("%d", &c[i][j]);
		}
	}
	if (n > 1) {
		fore(i, 1, n - 1) {
			int ai = c[i][0] - c[0][0];
			forn(j, n) {
				if (c[i][j] - c[0][j] != ai) {
					//printf("i = %d j = %d ai = %d %d\n", i, j, ai, c[i][j] - c[0][j]);
					printf("No");
					exit(0);
				}
			}
		}
	}
	int upper = c[0][0];
	forn(j, n) {
		upper = min(upper, c[0][j]);
	}
	int lower = 0;
	forn(i, n) {
		forn(j, n) {
			lower = max(lower, c[0][j] - c[i][j]);
		}
	}
	if (lower <= upper) {
		int a0 = lower;
		vi b(n);
		forn(i, n) {
			b[i] = c[0][i] - a0;
			assert(b[i] >= 0);
		}
		printf("Yes\n");
		forn(i, n) {
			int val = c[i][0] - b[0];
			assert(val >= 0);
			printf("%d ", val);
		}
		printf("\n");
		forn(i, n) {
			printf("%d ", b[i]);
		}
	} else {
		printf("No");
	}
}

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

int n;
vector<ll> a, b;

bool solve()
{
    cin >> n;
    vector<vector<ll>> c(n, vector<ll>(n));
    a.resize(n), b.resize(n);

    ll sum = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
        {
            cin >> c[i][j];
            sum += c[i][j];
        }

    if (sum % n != 0)
        return false;

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

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n - 1; j++)
            if (c[i][j + 1] - c[i][j] != c[mnidx][j + 1] - c[mnidx][j])
                return false;

    for (int i = 0; i < n; i++)
        b[i] = c[mnidx][i];

    for (int i = 0; i < n; i++)
        a[i] = c[i][0] - c[mnidx][0];

    return true;
}

int main()
{
    if (solve() == false)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        for (int i = 0; i < n; i++)
            cout << a[i] << " ";
        cout << endl;
        for (int i = 0; i < n; i++)
            cout << b[i] << " ";
        cout << endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int arr[] = {0,1,2,3,4,5,6,7,8,9};
map<char,int> mp;
LL getInt(string s){
    reverse(s.begin(), s.end());
    LL res = 0;
    LL base = 1;
    for(char c : s){
        res += base * arr[mp[c]];
        base *= 10;
    }

    return res;

}

bool check(string s){
    int idx = mp[s[0]];
    int x = arr[idx];
    if(x == 0) return false;
    else return true;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string A,B,C; cin >> A >> B >> C;
    set<char> se;
    for(char c : A) se.insert(c);
    for(char c : B) se.insert(c);
    for(char c : C) se.insert(c);
    int len = 0;
    for(char c : se) len++;
    if(len > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int idx = 0;
    for(char c : se){
        mp[c] = idx;
        idx++;
    }

    do{
        if(!check(A) || !check(B) || !check(C)) continue;
        LL Ax = getInt(A);
        LL Bx = getInt(B);
        LL Cx = getInt(C);

        if(Ax + Bx == Cx){
            cout << Ax << endl;
            cout << Bx << endl;
            cout << Cx << endl;
            return 0;
        }

    }while(next_permutation(arr, arr+10));

    cout << "UNSOLVABLE" << endl;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr ll INF = 1e18;
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<ll>> c(n, vector<ll>(n, 0));
    rep (i, n) rep (j, n) cin >> c[i][j];
    rep (i, n) rep (j, n) {
        if (c[i][j] - c[i][0] != c[0][j] - c[0][0]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n"; // 忘れない！
    vector<ll> a(n, INF), b(n, INF);
    rep (i, n) rep (j, n) {
        chmin(a[i], c[i][j]);
        chmin(b[j], c[i][j]);
    }
    ll am = *min_element(all(a)), bm = *min_element(all(b));
    transform(all(a), a.begin(), [&](ll x){return x - am;});
    // transform(all(b), b.begin(), [&](ll x){return x - bm;});
    rep (i, n) cout << a[i] << " \n"[i + 1 == n];
    rep (i, n) cout << b[i] << " \n"[i + 1 == n];
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>

using namespace std;

using ll = long long;
using veci = vector<int>;
using vecd = vector<double>;
using vecl = vector<long long>;

bool check_slope(int x1,int y1,int x2,int y2){
    int bigx,smallx,bigy,smally;
    if(x1<x2){
        bigx=x2;
        smallx=x1;
        bigy=y2;
        smally=y1;
    }
    else{
        bigx=x1;
        smallx=x2;
        bigy=y1;
        smally=y2;
    }
    /*
    double a=(double)(bigy-smally)/(bigx-smallx);
    cout<<" "<<a;
    */
    if(bigy-smally>bigx-smallx || bigy-smally<smallx-bigx) return false;
    else return true;
}

void Main(){
    int n,ans=0;
    cin>>n;
    veci x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {
        //cout<<i<<" "<<j;
        if(check_slope(x[i],y[i],x[j],y[j])){
            ans++;
            //cout<<" ok";
        }
        //cout<<endl;
    }
    cout<<ans;
    return;
}

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

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define FI first
#define SE second
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define endl '\n'
#define double long double
#define OOK order_of_key  //no of elements strictly less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/

signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n;
    cin>>n;
    int ans=INF;
    for(int i=0;i<61;i++)
    {
        int x=1ll<<i;
        if(x<=n)
        {
            int z=n%x;
            int y=(n-z)/x;
            ans=min(ans,i+y+z);
        }
    }
    cout<<ans<<endl;
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll> pql;
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5;
const ld eps = 1e-9;
const char newl = '\n';

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

  ll n, x;
  cin >> n >> x;
  vl a(n);
  rep3(i, n-1, 0) cin >> a[i];

  map<ll, ll> dp[n+1];
  dp[0][x] = 1;
  rep(i, n) for(pl p: dp[i]) {
      ll d = p.first - a[i]*(p.first/a[i]);
      dp[i+1][d] += p.second;
      if(i==0 || abs(p.first) + a[i] < a[i-1]) {
        if(d>0) dp[i+1][d-a[i]] += p.second;
        if(d<0) dp[i+1][d+a[i]] += p.second;
      }
  }
  cout << dp[n][0] << newl;
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> b(n);
  for (int i = n - 1; i >= 0; i--) {
    b[i] = x / a[i];
    x %= a[i];
  }
  vector<int> next(n - 1);
  for (int i = 0; i < n - 1; i++) {
    next[i] = n - 1;
    for (int j = i + 1; j < n - 1; j++) {
      if (b[j] != a[j + 1] / a[j] - 1) {
        next[i] = j;
        break;
      }
    }
  }
  vector<long long> dp(n - 1, 0);
  for (int i = 0; i < n - 1; i++) {
    if (b[i] > 0) {
      dp[i] = 1;
      for (int j = i - 2; j >= 0; j--) {
        if (i > next[j]) {
          dp[i] += dp[j];
        }
      }
    }
    if (b[i] != a[i + 1] / a[i] - 1 && i > 0) {
      for (int j = 0; j < i; j++) {
        if (next[j] == i) {
          dp[i] += dp[j];
        }
      }
    }
  }
  cout << accumulate(dp.begin(), dp.end(), 0ll) + 1 << '\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;
#define endl '\n'
#define pb push_back
#define fast   ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve(){

   double a,b,c,d; cin>>a>>b>>c>>d;

   double ans = a/(c*d - b);

   if(ans < 0 || d*c == b) cout<<-1;
   else 	cout<<ceil(ans);

}

int main(){
	fast
	int t=1; //cin>>t;
	while(t--){
		solve();
		cout<<endl;
	}
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sc(x) scanf("%lld",&(x));
#define fi first
#define se second
#define endl '\n'
int n;
int a,b,c,d;

int ans;
signed main(){
    sc(a)sc(b)sc(c)sc(d)
    if(b > d*c){
        cout << -1 << '\n';
    }else if(b == d*c){
        if(a == 0){
            cout << 1 <<'\n';
        }else{
            cout << -1 << '\n';
        }
    }else{
        for(int i = 1; i <= 100000; i++){
            if(a + i*(b)<= i*d*c){
                cout << i << '\n';
                break;
            }
        }

    }

}


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

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    set<ll> s;
    for (ll i = 2; i * i <= N; i++)
    {
        ll x = i * i;
        while (x <= N)
        {
            s.insert(x);
            x *= i;
        }
    }
    cout << N - s.size() << endl;

    return 0;
}

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

// 約数列挙
vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {

	ll n; cin >> n;
    vector<long long> div = calc_divisor(n);
    for (int i = 0; i < div.size(); i++) {
        cout << div[i] << endl;
    }
	return 0;
}