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

int main() {
    int long long n, k;

    while (cin >> k >> n) {

        if (ceil(k / 2.0) >= n){

            cout << (n * 2) - 1 << endl;

        }
        else{
            int long long j= (n - ceil(k / 2.0)) * 2;
            cout << j << endl;
        }
    }return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int i,j=0,n,c,sum=0,x,a,b,f=0;
int base(int k,int l)
{
    sum=0;
    while(k!=0)
    {
        sum+=k%l;
        k/=l;

    }
    return sum;
}
int gcd(int a,int b)
{
    return(b==0?a:gcd(b,a%b));
}
int main()
{   f=0;
    cin>>n;
    for(i=2;i<n;i++)
        f+=base(n,i);
        j=gcd(f,n-2);
       cout<<(f/j)<<"/"<<(n-2)/j<<endl;
}


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

typedef struct _Data
{
	char name_[30];
	int  score_;
	int  x_;
	int  y_;
	int flag;
}Data;

int search(char *temp, Data *data);
void change(Data *a, Data *b);
void sort(Data *data);

int main()
{
	char temp[50];
	Data data[10] = {0};
	int i, j = 0;

	for (i = 0; i < 5; ++i)
	{
		int a, b, t;
		scanf("%s", temp);
		if ((t = search(temp, data)) != -1)
			a = t;
		else
		{
			a = j++;
			strcpy(data[a].name_, temp);
		}
		scanf("%s", temp);
		if ((t = search(temp, data))!=-1)
			b = t;
		else
		{
			b = j++;
			strcpy(data[b].name_, temp);
		}
		int m, n;
		scanf("%d:%d", &m, &n);
		if (m > n)
			data[a].score_ += 3;
		else if (m == n)
		{
			data[a].score_ += 1;
			data[b].score_ += 1;
		}
		else
			data[b].score_ += 3;
		data[a].flag++;
		data[b].flag++;
		data[a].x_ += m;
		data[b].x_ += n;
		data[a].y_ += n;
		data[b].y_ += m;
	}

	for (i = 1; i < 50; ++i)
	{
		for (j = 0; j <= 50-i; j++)
		{
			int a, b, k1, k2;
			a = j + i, b = j;
			k1=search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			data[k1].score_ += 3;
			data[k1].x_ += a;
			data[k2].x_ += b;
			data[k1].y_ += b;
			data[k2].y_ += a;
			sort(data);
			k1 = search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			if (k1+1 == 1 || k1+1 == 2)
			{
				printf("%d:%d\n", a, b);
				return 0;
			}
			k1 = search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			data[k1].score_ -= 3;
			data[k1].x_ -= a;
			data[k2].x_ -= b;
			data[k1].y_ -= b;
			data[k2].y_ -= a;
		}
	}
	printf("IMPOSSIBLE");

	return 0;
}

int search(char *temp,Data *data)
{
	int i;

	for (i = 0; i < 4; ++i)
		if (!strcmp(temp, data[i].name_))
			break;
	if (i < 4)
		return i;
	else
		return -1;
}

void sort(Data *data)
{
	int i, j;

	for (i = 0; i < 4; ++i)
	{
		for (j = 0; j < 4 - i; ++j)
		{
			if (data[j].score_ == data[j+1].score_)
			{
				if (data[j].x_ - data[j].y_ == data[j + 1].x_ - data[j + 1].y_)
				{
					if (data[j].x_ == data[j + 1].x_)
					{
						if (strcmp(data[j].name_, data[j + 1].name_) > 0)
							change(&data[j], &data[j + 1]);
					}
					else if(data[j].x_ < data[j + 1].x_)
						change(&data[j], &data[j + 1]);
				}
				else if(data[j].x_ - data[j].y_ < data[j + 1].x_ - data[j + 1].y_)
					change(&data[j], &data[j + 1]);
			}
			else if(data[j].score_ < data[j + 1].score_)
				change(&data[j], &data[j + 1]);
		}
	}
}

void change(Data *a, Data *b)
{
	Data t;

	t = *a;
	*a = *b;
	*b = t;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using P = pair<int,int>;
const int INF = 1e9;
P operator + (const P &p, const P &q) {return P(p.first + q.first, p.second + q.second);}

void warshall_floyd(int n, vector<vector<P>>& d){
  rep(k,n){
    rep(i,n){
      rep(j,n) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}

int main(){
  int n;
  cin >> n;
  int a[n][n];
  int s = 3*n*n;
  int squ = n*n;
  int number[n*n];
  rep(i,n) {
    rep(j,n) {
      scanf("%d",&a[i][j]);
      a[i][j]--;
      number[a[i][j]] = n*i+j;
    }
  }
  vector<P> knight, bishop, rook;
  vector<vector<P>> d(s,vector<P>(s,P(INF,INF)));
  rep(x,n) {
    rep(y,n) {
      rep(nx,n) {
        rep(ny,n) {
          if(x == nx && y == ny) continue;
          if((abs(x-nx) == 1 && abs(y-ny) == 2) || (abs(x-nx) == 2 && abs(y-ny) == 1)) knight.push_back(P(x*n+y,nx*n+ny));
          if(abs(x-nx) == abs(y-ny)) bishop.push_back(P(x*n+y,nx*n+ny));
          if(abs(x-nx) == 0 || abs(y-ny) == 0) rook.push_back(P(x*n+y,nx*n+ny));
        }
      }
    }
  }
  for(auto p : knight) d[p.first][p.second] = P(1,0);
  for(auto p : bishop) d[squ+p.first][squ+p.second] = P(1,0);
  for(auto p : rook) d[2*squ+p.first][2*squ+p.second] = P(1,0);
  rep(x,n) {
    rep(y,n) {
      int pos = x*n + y;
      rep(j,3) {
        int l = (j + 1) % 3;
        d[j*squ+pos][l*squ+pos] = P(1,1);
        d[l*squ+pos][j*squ+pos] = P(1,1);
      }
    }
  }
  warshall_floyd(s,d);
  P ans[n*n][3];
  rep(i,n*n) rep(j,3) ans[i][j] = P(INF,INF);
  rep(i,3) ans[0][i] = P(0,0);
  for(int i = 1; i < n*n; i++) {
    rep(j,3) {
      rep(k,3) ans[i][j] = min(ans[i][j],ans[i-1][k]+d[k*squ+number[i-1]][j*squ+number[i]]);
    }
  }
  P output = P(INF,INF);
  rep(i,3) output = min(ans[n*n-1][i],output);
  printf("%d %d\n",output.first,output.second);
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <iostream>

using namespace std;
typedef long long lli;
typedef pair<int, int> pii;

int main()
{
    // freopen("in.txt", "r", stdin);
    int n, arr[101];
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &arr[i]);
    if(n % 2 == 0 || arr[1] % 2 == 0 || arr[n] % 2 == 0) { printf("No"); exit(0); }
    int set = 0;
    for(int i = 1; i <= n; i++)
    {
        set++;
        if(i+1 <= n && arr[i+1] % 2 == 0) i += 2;
    }
    if(set % 2 == 0) printf("No");
    else printf("Yes");
}


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

#define rep(i,n) for( i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9

typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

#define mx 0

int main() {
long long int i,j,k,n;
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    if(k>=n/2)
    {   j=n*(n-1)/2;
    	cout<<j;
    	return 0;
	}
	else
	{

		long long int x;
		x+=n-1;
		for(i=2;i<=k;i++)
		{x+=n-i+i-1;

		}
		 x+=(n-k*2)*k;
		cout<<x;
		return 0;
	}
    return 0;
}


#include <iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll x,y,x2,y2,ans;
int main()
{
    cin>>x>>y>>x2>>y2;
    ans=max(abs(x-x2),abs(y-y2));
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
char ch [ ] = {'R','G','B','Y'};
int main()
{
    string a , bb ;
    cin >> a ;
    int ln = ( int ) a.size() ;
    int x = 0 ;
    bb = a ;
    while ( true ){
        int cnt = 0 ;
        for( int i = 0 ; i < ln ; i ++  ){
            if ( a [ i ] == '!' ) cnt ++ ;
        }
        if ( cnt == 0 ) break ;
        int in = 0 ;
        for( int i = 0 ; i < ln ; i ++ ) {
            if ( a [ i ] == ch [ x  ]){
                in = i ;
                x ++ ;
                break ;
            }
        }
        for( int i = in ; i < ln ; i +=4){
            a [ i ] = a [ in ];
        }
        for( int i = in ; i >= 0 ; i -=4 ){
            a[ i ] = a[ in ] ;
        }
    }
    int r = 0 , b = 0 , y = 0 , g = 0 ;
    for( int i = 0 ; i < ln ; i ++ ){
        if ( bb [ i ] == '!'){
            if ( a [ i ] == 'R')r ++ ;
            else if ( a[ i ] == 'B') b ++ ;
            else if ( a [ i ] == 'Y') y ++ ;
            else g ++ ;
        }
    }
    //cout << a << endl;
    cout << r << " " << b << " " << y << " " << g << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[5];
int u[4];
bool f[5],falg;
void dfs(int dep)
{
    if(dep==4)
    {
        if(u[1]+u[2]>u[3]&&u[1]+u[3]>u[2]&&u[2]+u[3]>u[1])
        {
            printf("TRIANGLE");
            exit(0);
        }
        if(u[1]+u[2]>=u[3]&&u[1]+u[3]>=u[2]&&u[2]+u[3]>=u[1])falg=true;
        return;
    }
    for(int i=1;i<=4;i++)
    if(f[i]==false)
    {
        f[i]=true;
        u[dep]=a[i];
        dep++;
        dfs(dep);
        dep--;
        u[dep]=0;
        f[i]=false;
    }
}
int main()
{
    scanf("%d%d%d%d",a+1,a+2,a+3,a+4);
    dfs(1);
    if(falg==true)printf("SEGMENT");
    else printf("IMPOSSIBLE");
return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <ctime>
#include <complex>

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define x first
#define y second
#define sqr(x) (((x) + .0) * ((x) + .0))

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<db, db> pt;

const int maxn = 100500;
const int infi = (1 << 30);
const ll infl = (1LL << 62);
const db eps = 1e-9;
const ll mod = 1000000007LL;
const db pi = acos(-1.0);

bool ok(int c, int a, int b) {
	while (c) {
		if (c % 10 != a && c % 10 != b) {
			return false;
		}
		c /= 10;
	}
	return true;
}

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

int a, b, n;
ll ans, f[1000001];

int main() {

	cin >> a >> b >> n;
	ans = 0;
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}
	for (int i = 0; i <= n; i++) {
		if (ok(a * i + (n - i) * b, a, b))
			ans = (ans + ((f[n] * bin_pow(f[i], mod - 2)) % mod * bin_pow(f[n - i], mod - 2)) % mod) % mod;
	}
	cout << ans << endl;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,**a;
	cin>>n;
	a=new int*[n];
	for(int i=0;i<n;i++)
    	a[i]=new int [n];
    for(int i=0;i<n;i++)
	{
     	for(int j=0;j<n;j++)
     	{
     		if(j==0 || i==0)
     		   a[i][j]=1;
     		else
     	    	a[i][j]=a[i-1][j]+a[i][j-1];
		}
    }
   	cout<<a[n-1][n-1];
}


#include <iostream>
#include<algorithm>

int main() {
    int n = 0;
    std::cin>> n;

    int m = 0;
    std::cin>> m;

    int a[25];
    int b[25];

    for (int i = 0; i < m; ++i) {
        std::cin>> a[i];
        std::cin>> b[i];
    }
    //std::cout<< "done reading\n";

    int total = 0;
    int handle = 0;
    for (int i = 0; i < m; ++i) {
        total += a[i]*b[i];
        handle += a[i];
    }
    if (handle <= n) {
        std::cout<< total<< '\n';
        return 0;
    }
    total = 0;

    while (n > 0) {
        //std::cout<< n<< ' ';
        int ind = 0;
        // We determine first the boxes with the highest matches
        for (int i = 0; i < m; ++i) {
            if (b[i] > b[ind]) {
                ind = i;
            }
        }

        //std::cout<< ind<< ' ';
        if (n <= a[ind]) {
            total = total + n * b[ind];
            a[ind] -= n;
            n = 0;
            std::cout<< total<< '\n';
            return 0;
        } else {
            total += a[ind]*b[ind];
            n -= a[ind];
            a[ind] = 0;
            b[ind] = 0;
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
	long long unsigned n;
	cin >> n;
	long long unsigned r = 1 + 3*n*(n + 1);
	cout << r << endl;
	//system("pause");
}


#include "algorithm"
#include "iostream"
#include "string"
using namespace std;
int main()
{
    int n;
    cin >> n;
    int home, guest, answer = 0;
    int data[128][2] = {0};
    for (int i = 0; i < n; ++i)
    {
        cin >> home >> guest;
        ++data[ home][0];
        ++data[guest][1];
    }
    for (int i = 1; i < 101; ++i)
    {
        answer +=  data[i][0] * data[i][1];
    }
    cout << answer << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

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

#define pb push_back
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define mset(a, v) memset(a, v, sizeof(a))

#define dbn cerr << "\n"
#define dbg(x) cerr << #x << " : " << x << " "
#define dbs(x) cerr << x << " "

const int N = 111;
const int K = 11;
const int mod = (int)1e8;

int dp[N][N][K][K];
int n1, n2, k1, k2;

inline void add(int &a, int b) {
    a += b;
    if(a >= mod) a -= mod;
}

int go(int pos1, int pos2, int cnt1, int cnt2) {
    if(pos1 == n1 and pos2 == n2) return 1;
    int & ret = dp[pos1][pos2][cnt1][cnt2];
    if(~ret) return ret;
    ret = 0;
    if(pos1 < n1 and cnt1 + 1 <= k1) {
        add(ret, go(pos1 + 1, pos2, cnt1 + 1, 0));
    }
    if(pos2 < n2 and cnt2 + 1 <= k2) {
        add(ret, go(pos1, pos2 + 1, 0, cnt2 + 1));
    }
    return ret;
}

int main() {
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    mset(dp, -1);
    cin >> n1 >> n2 >> k1 >> k2;
    cout << go(0, 0, 0, 0) << '\n';
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = max(x1, x2 + 1) - min(x1, x2 - 1);
    int dy = max(y1, y2 + 1) - min(y1, y2 - 1);
    cout << 2 * dx + 2 * dy << endl;
}


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

#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    int n, m, mn, mx;

    cin >> n >> m >> mn >> mx;

    bool is_mn = false;
    bool is_mx = false;

    for (int i = 0; i < m; ++i) {
        int x;
        scanf("%d", &x);
        if (x < mn || x > mx) {
            cout << "Incorrect" << endl;
            return 0;
        }
        if (x == mn) {
            is_mn = true;
        }
        if (x == mx) {
            is_mx = true;
        }
    }

    if (mn == mx) {
        cout << "Correct" << endl;
    } else {
        int d = !is_mn + !is_mx;
        if (m + d <= n) {
            cout << "Correct" << endl;
        } else {
            cout << "Incorrect" << endl;
        }
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<climits>
#include<cmath>
#include<vector>
#include <bitset>
#include<algorithm>
#include <queue>
#include<map>
#define inf 9999999;
using namespace std;
int n , a , b , c , d;
int main()
{
    cin >> n >> a >> b >>c >>d;
    int t1 = 0 , t2 = 0;
    if(a == 0) t1 = b;
    else if(a == n) t1 = 3 * n - b;
    else if(b == 0) t1 = 4 * n - a;
    else t1 = n + a;
    if(c == 0) t2 = d;
    else if(c == n) t2 = 3 * n - d;
    else if(d == 0) t2 = 4 * n - c;
    else t2 = n + c;
    printf("%d\n" , min(abs(t1 - t2) , 4 * n - abs(t1 - t2)));

}


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

#define LL long long
#define vi vector<LL>
#define pub push_back
#define pob pop_back
#define Fst first
#define Snd second
#define Debug(x) cout << x << endl
#define fo(i,a,b) for (int i=a; i<b; i++)
#define fu(i,a,b) for (int i=a; i<=b; i++)
#define FO(i,a,b) for(vi::iterator i = a; i != b; i++)

const LL MOD = 1000000007LL, INF = 1e9, LINF = 1e18;

LL GT(int x){
	return (x <= 1) ? 1 : x*GT(x-1);
}

LL tohop(LL n, LL k){
	LL c = 1;
	for (LL i=1; i<=k; i++, n--) c = c*n/i;
	return c;
}

bool SNT(int x){
	if (x == 1) return false;
	fu(i,2,sqrt(x))
		if (x%i == 0) return false;
	return true;
}

void solve(){
	//r > b > y
	LL y, b, r;
	cin >> y >> b >> r;
	Debug(min(3*y+3, min(3*b,3*r-3)));
	return;
}

int main(){
	#ifdef ONLINE_JUDGE
	    ios::sync_with_stdio(0);
		cin.tie(0);
	#endif
//	int query;
//	cin >> query;
//	while (query--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,R,B,r[18],b[18],N=256;
int Av,Bv,rem,cost,movie,nmask,type,token,mask,bit;
int dp[(1<<(16))+5][2][260];
char c[18];
main () {
 cin>>n;

 for (int i=0; i<n; i++) {
  cin>>c[i]>>r[i]>>b[i];
  Av+=max(0,r[i]-n);
  Bv+=max(0,b[i]-n);
  r[i]=min(r[i],n);
  b[i]=min(b[i],n);
 }

 N=n*n;

 int card[2],s[2],ans=1e9;

 for (mask=0; mask<(1<<n); ++mask)
  for (type=0; type<=1; type++)
   for (token=0; token<=N; ++token)
     dp[mask][type][token]=1e9;

 if (Av>Bv) {
  dp[0][1][min(N,Av-Bv)]=max(Av,Bv);
 }
  else {
  dp[0][0][min(N,Bv-Av)]=max(Av,Bv);
 }

 for (mask=0; mask<(1<<n); ++mask) {
  card[0]=card[1]=0;
  for (bit=0; bit<n; ++bit) {
   if ((1<<bit)&mask) {
    if (c[bit]=='R')
     card[0]++;
      else
     card[1]++;
   }
  }

  for (type=0; type<=1; ++type) {
   for (token=0; token<=N; ++token) {
    if (__builtin_popcount(mask)==n) {
      ans=min(ans,dp[mask][type][token]);
    }

    for (bit=0; bit<n; ++bit) {
     if (!((1<<bit)&mask)) {
      R=max(0,r[bit]-card[0]);
      B=max(0,b[bit]-card[1]);

      s[0]=s[1]=0;
      s[type]=token;

      cost=max(R-s[0],B-s[1]);
      movie=dp[mask][type][token]+cost;
      nmask=(mask|(1<<bit));

      if (R-s[0]>B-s[1]) {
        rem=min(n*n,s[1]+cost-B);
        dp[nmask][1][rem]=min(movie,dp[nmask][1][rem]);
      }
        else {
        rem=min(n*n,s[0]+cost-R);
        dp[nmask][0][rem]=min(movie,dp[nmask][0][rem]);
      }
     }
    }
   }
  }
 }

 cout<<ans+n<<"\n";
}


//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

void wczytaj(PII& a)
{
  string s;
  cin>>s;
  a.fi = s[0];
  a.se = s[1];
}

int main()
{
	_upgrade
  PII a;
  wczytaj(a);
  bool f = 0;
  for(int i = 0 ;i < 5;i++)
  {
    PII cnt;
    wczytaj(cnt);
    if(a.fi == cnt.fi || a.se == cnt.se)
      f = 1;
  }
  cout<<(f == 0 ? "NO" : "YES");

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define sz(a)	ll(a.size())
#define debug1(x) cout<<x<<endl
#define debug2(x,y) cout<<x<<"-->"<<y<<endl
#define debug3(x,y,z) cout<<x<<"-->"<<y<<"-->"<<z<<endl
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;
map<ll,ll> counter;
int x[5],y[5],X[5],Y[5],c[6],m[5],xmin=INT_MAX,xmax=INT_MIN,Xmax=INT_MIN,Xmin=INT_MAX,ymin=INT_MAX,ymax=INT_MIN,Ymax=INT_MIN,Ymin=INT_MAX;
bool check(int i,int j)
{
	// cout<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax<<ln;
	if(i>=xmin && i<=xmax && j<=ymax && j>=ymin)return 1;
	return 0;
}
bool check1(int xx,int yy)
{
	int t1,t2,t3;
	FOR(i,0,2)
	{
		t1=c[i];
		t2=c[i+2];
		t3=yy-m[i]*xx;
		// cout<<t1<<" "<<t2<<ln;
		if(t3<min(t1,t2) || t3>max(t1,t2))return 0;
	}
	return 1;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	FOR(i,0,4)
	 	{
	 		cin>>x[i]>>y[i];
	 		xmin=min(xmin,x[i]);
	 		xmax=max(xmax,x[i]);
	 		ymin=min(ymin,y[i]);
	 		ymax=max(ymax,y[i]);
	 	}
	 	FOR(i,0,4)
	 	{
	 		cin>>X[i]>>Y[i];
	 		Xmin=min(Xmin,X[i]);
	 		Xmax=max(Xmax,X[i]);
	 		Ymin=min(Ymin,Y[i]);
	 		Ymax=max(Ymax,Y[i]);

	 	}
	 	FOR(i,0,3)
	 	{
	 		m[i]=(Y[i+1]-Y[i])/(X[i+1]-X[i]);
	 		c[i]=Y[i]-m[i]*X[i];
	 	}
	 	m[3]=(Y[0]-Y[3])/(X[0]-X[3]);
	 	c[3]=Y[3]-m[3]*X[3];
	 	FOR(i,-100,101)
	 	{
	 		FOR(j,-100,101)
	 		{
	 			// cout<<check(i,j)<<" "<<check1(i,j)<<ln;
	 			if(check(i,j) && check1(i,j))
	 			{
	 				// cout<<i<<" "<<j<<ln;
	 				cout<<"YES\n";
	 				return 0;
	 			}
	 		}
	 	}
	 	cout<<"NO\n";
	 	return 0;
		return 0;
}


#include <cstdio>
#include <algorithm>

char plrA[] = "BitLGM";
char plrB[] = "BitAryo";

#define N 500

int n;
int arr[3];
bool win[N+1][N+1] = {};

int main()
{
    for (int i = 1; i <= N; ++i) {
        win[0][i] = win[i][0] = true;
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {

            // try remove all
            for (int k = std::min(i, j); k >= 1; --k) {
                if (!win[i-k][j-k]) {
                    win[i][j] = true;
                    break;
                }
            }

            // try remove left
            for (int k = 0; k < i; ++k) {
                if (!win[k][j]) {
                    win[i][j] = true;
                    break;
                }
            }

            // try remove right
            for (int k = 0; k < j; ++k) {
                if (!win[i][k]) {
                    win[i][j] = true;
                    break;
                }
            }
        }
    }

    while (true) {

        scanf("%d", &n);
        if (n == 0)
            break;

        if (n == 1) {
            scanf("%d", &arr[0]);
            printf(arr[0] == 0 ? plrB : plrA);
        } else if (n == 3) {
            scanf("%d%d%d", &arr[0], &arr[1], &arr[2]);
            printf((arr[0] ^ arr[1] ^ arr[2]) != 0 ? plrA : plrB);
        } else {

            scanf("%d%d", &arr[0], &arr[1]);
            printf(win[arr[0]][arr[1]] ? plrA : plrB);
        }

        printf("\n");
        break;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
string a,b;
int n;
int Next[1000010];

void change()
{
  for(int i=0;i<n-1;i++)
  {
    if(b[i] == 'W') b[i] = 'E';
    else if(b[i] == 'S') b[i] = 'N';
    else if(b[i] == 'N') b[i] = 'S';
    else if(b[i] == 'E') b[i] = 'W';
  }
  reverse(b.begin(),b.end());
  return;
}

void NEXT()
{
  for(int i=1;i<n-1;i++)
  {
    int j=i;
    while(j>0)
    {
      j=Next[j];
      if(b[j]==b[i])
      {
        Next[i+1]=j+1;
        break;
      }
    }
  }
  return;
}

void kmp()
{
  int j=0;
  for(int i=0;i<n-1;i++)
  {
    while(j && b[j]!=a[i])
      j=Next[j];
    if(b[j]==a[i])
      j++;
  }
  if(j == 0) printf("YES\n");
  else printf("NO\n");
}

int main()
{
  scanf("%d",&n);
  cin>>a>>b;
  change();
  NEXT();
  kmp();
}


#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=25;
const int dx[]={1,2,2,1,-1,-2,-2,-1,0,3,0,-3};
const int dy[]={2,1,-1,-2,-2,-1,1,2,3,0,-3,0};
int n,m,mat[N*N],vis[N*N],x[]={0,0,0,0,2,4};
vector<int> g[N];
inline int id(int x,int y){return (x-1)*m+y;}
int find(int x){
	for(auto to:g[x]){
		if(vis[to])	continue;	vis[to]=1;
		if(!mat[to]||find(mat[to])){
			mat[to]=x;	return 1;
		}
	}
	return 0;
}
int solve(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)	if((i+j)%2){
			for(int k=0;k<12;k++){
				int tx=i+dx[k],ty=j+dy[k];
				if(tx>=1&&tx<=n&&ty>=1&&ty<=m)	g[id(i,j)].push_back(id(tx,ty));
			}
		}
	}
	int res=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)	if((i+j)%2){
			memset(vis,0,sizeof vis);
			if(find(id(i,j)))	res++;
		}
	}
	return res*2;
}
signed main(){
	cin>>n>>m;	if(n>m)	swap(n,m);
	if(n==1)	printf("%lld",m/6*6+x[m%6]);
	else if(n<=8&&m<=8)	cout<<solve();
	else{
		printf("%lld",n%2&&m%2?1ll*n*m-1:1ll*n*m);
	}
	return 0;
}


#include <iostream>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss

const int N = 3e3 + 10;

int r, c, n, k;
pair<int, int> a[N];
vector<int> g[N];
int prv[N], nxt[N];
int cu, cv, u[N], v[N], take[N];
int cur_ans;
long long ans;

bool cmp(pair<int, int> u, pair<int, int> v) {
	if (u.sc != v.sc) return u.sc < v.sc;
	return u.fr < v.fr;
}

int getPrv(int x) {
	if (x < 0) return x;
	if (prv[x] != x) prv[x] = getPrv(prv[x]);
	return prv[x];
}

int getNxt(int x) {
	if (x == n) return x;
	if (nxt[x] != x) nxt[x] = getNxt(nxt[x]);
	return nxt[x];
}

void ers(int x) {
	if ((x == 0) || (x == n - 1)) return;
	cu = cv = 0;
	for (int i = x; (cu <= k); i = getPrv(i - 1)) {
		u[cu++] = i;
		if (u[cu - 1] == 0) break;
	}
	for (int i = x; (cv <= k); i = getNxt(i + 1)) {
		v[cv++] = i;
		if (v[cv - 1] == n - 1) break;
	}
	// cerr << cu << " " << cv << endl;
	// for (int i = 0; i < cu; i++) cerr << u[i] << " ";
	// 	cerr << endl;
	// for (int i = 0; i < cv; i++) cerr << v[i] << " ";
	// 	cerr << endl;
	prv[x] = x - 1;
	nxt[x] = x + 1;
	for (int i = 0; i + 1 < cu; i++) {
		if (k-i < cv) {
			cur_ans -= (a[u[i]].sc - a[u[i+1]].sc) * (a[v[k-i]].sc - a[v[k-i-1]].sc);
		}
	}

}

int main() {
	// freopen("input.txt", "r", stdin);
	scanf("%d%d%d%d", &r, &c, &n, &k);
	// r = c = n = 3000;
	//k = 10;
	vector< vector<bool> > used(n, vector<bool>(n));
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i].fr, &a[i].sc);
		--a[i].fr; --a[i].sc;
		// a[i] = mp(i + 1, n - i);
		// a[i].fr = rand() % r;
		// a[i].sc = rand() % c;
		// while (used[a[i].fr][a[i].sc]) {
		// 	a[i].fr = rand() % r;
		// 	a[i].sc = rand() % c;
		// }
		// used[a[i].fr][a[i].sc] = 1;
	}
	a[n++] = mp(r-1, -1);
	a[n++] = mp(r-1, c);
	sort(a, a + n, cmp);
	for (int i = 0; i < n; i++) {
		g[a[i].fr].pb(i);
	}
	for (int i = 0; i < r; i++) {
		memset(take, 0, sizeof(take));
		for (int j = i; j < r; j++) {
			for (int e = 0; e < (int)g[j].size(); e++) take[g[j][e]] = 1;
		}
		// cerr << i << ": ";
		// for (int j = 0; j < c; j++) cerr << take[j] << " ";
		// cerr << endl;
		int lst = 0;
		for (int j = 0; j < n; j++) {
			if (take[j]) lst = j;
			prv[j] = lst;
		}
		lst = n - 1;
		for (int j = n - 1; j >= 0; j--) {
			if (take[j]) lst = j;
			nxt[j] = lst;
		}
		int v = 0, cs = 0;
		cur_ans = 0;
		for (int u = 1; (u + 1 < n) && (v + 1 < n); u++) {
			while ((v + 1 < n) && (cs < k)) {
				++v;
				cs += take[v];
			}
			// cerr << cs << endl;
			cur_ans += (a[u].sc - a[u - 1].sc) * (c - a[v].sc);
			cs -= take[u];
		}
		// cerr << i << " " << r - 1 << ": " << cur_ans << endl;
		for (int j = r - 1; j >= i; j--) {
			ans += cur_ans;
			for (int e = 0; e < (int)g[j].size(); e++) ers(g[j][e]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main(){
	int t;cin>>t;
	for(int i=0;i<t;i++){
		int x,n=0;cin>>x;
		int s=(x%10-1)*10;
		if(x%10==x) n=1;
		else if(x%100==x) n=3;
		else if(x%1000==x) n=6;
		else n=10;
		cout<<s+n<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<cmath>
using namespace std;
//for(i=0;i<n;i++)//

int main()
{int n=0,i=0,j=0,c=0,L=0,R=0,X=0,Y=0;
cin>>n>>c;
int p[n],t[n];

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

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

for(i=0;i<n;i++)
{X=X+t[i];
j=p[i]-c*X;
if(j<0)
{
j=0;
}
L=L+j;
}
for(i=n-1;i>=0;i--)
{ Y=Y+t[i];
j=p[i]-c*Y;
if(j<0)
{
j=0;
}
R=R+j;
}

if(L>R)
{cout<<"Limak";}
else if(L<R)
{cout<<"Radewoosh";}
else if(L==R)
{cout<<"Tie";}
return 0;
}


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

#define fr freopen("in.txt", "r", stdin);
#define fw freopen("out.txt", "w", stdout);
#define sd(x) scanf("%d", &x);
#define sl(x) scanf("%lld", &x);
#define sf(x) scanf("%lf", &x);
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mem(v, x) memset(v, x, sizeof(v));
#define EB emplace_back
#define PB push_back
#define MP make_pair

int main()
{
    ll l,r,a,b,k;
    sl(l);
    sl(r);
    sl(a);
    sl(b);
    sl(k);

    for (int x = a; x <= b; x++)
    {
        ll temp = k * x * 1LL;
        if (temp >= l && temp <= r)
        {
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");
}


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

int main() {

char a[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	int n,k;
	cin>>n>>k;
	char *b=new char [n];
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	sort(b,(b+n));
	char temp=b[0];
	int count=0;
	int sum=0;

	sum=(b[0]-'a')+1;
	count=1;
	int count2=1;
	int flag=1;
	int flag2=0;
for(int i=1;count<n&&count2<k;i++){
	//	cout<<b[count]<<endl;
		if(b[count]>temp&&temp+1!=b[count]-0&&temp!=b[count]){
				sum+=(b[count]-'a')+1;
				temp=b[count];
			count2++;
			flag++;

		}else{

		}

			count++;
	}
	if(flag==k){

		cout<<sum;

	}else{

		cout<<-1;
	}

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
string s1,s2,s3;
int main(){
	cin>>s1>>s2>>s3;
	s1=s1+s2;
	s1=s1+s3;
	for(int i=0;i<=3;i++){
		if(s1[i]!=s1[8-i]){
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int mod=1e9+7;
vector<long long int> dp(1e6+5,0);
unordered_map<long long int,long long int> a;
long long int n,m;

long long int ile(long long int dist)
{
    if(dist<=1000) return dp[dist];
    ll mid=dist/2;
    ll res=0;
    if(a[mid-1]==0) a[mid-1]=ile(mid-1);
    if(a[dist-mid]==0) a[dist-mid]=ile(dist-mid);
    res+=a[mid-1]*a[dist-mid];
    res%=mod;
    for(int i=0;i<m;i++)
    {
        ll p,r;
        p=mid-i-1;
        r=dist-(mid-i+m-1);
        if(a[p]==0) a[p]=ile(p);
        if(a[r]==0) a[r]=ile(r);
        res+=a[p]*a[r];
        res%=mod;
    }
    return res;
}

int main()
{
    cin>>n>>m;
    dp[0]=1;
    for(int i=1;i<=1000;i++)
    {
        dp[i]+=dp[i-1];
        if(i>=m) dp[i]+=dp[i-m];
        dp[i]%=mod;
    }
    cout<<ile(n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool Is_visible(double x, double y,double x1,double x2,double x3,double x4,double x5,double x6,double y1,double y2,double y3,double y4,double y5,double y6)
{
  if(x > std::max(x1,x2) || x < std::min(x1,x2) || y > std::max(y1,y2) || y < std::min(y1,y2))
  {
    return false;
  }
  else
  {
    if(x > std::max(x3,x4) || x < std::min(x3,x4) || y > std::max(y3,y4) || y < std::min(y3,y4))
    {
      if(x > std::max(x5,x6) || x < std::min(x5,x6) || y > std::max(y5,y6) || y < std::min(y5,y6))
      {
        return true;
      }
      else
      {
        return false;
      }
    }
    else
    {
      return false;
    }
  }
}
int main(int argc, char const *argv[])
{
  double x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
  std::cin >> x1 >> y1 >> x2 >> y2;
  std::cin >> x3 >> y3 >> x4 >> y4;
  std::cin >> x5 >> y5 >> x6 >> y6;
  if(x1 > x2)
  {
    swap(x1,x2);
    swap(y1,y2);
  }
  double ya = y1;
  double yb = y2;
  bool done = false;
  for(double x = std::min(x1,x2); x <= std::max(x1,x2) ; x+= 0.5)
  {
    if(Is_visible(x,ya,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6))
    {
      done = true;
      break;
    }
    if(Is_visible(x,yb,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6))
    {
      done = true;
      break;
    }
  }
  double xa = x1, xb = x2;
  for(double y = std::min(y1,y2); y <= std::max(y1,y2) ; y+= 0.5)
  {
    if(Is_visible(xa,y,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6))
    {
      done = true;
      break;
    }
    if(Is_visible(xb,y,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6))
    {
      done = true;
      break;
    }
  }
  if(done)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;

char s[123456];
char dir[42];

int main() {
  string w[3];
  w[0] = "qwertyuiop";
  w[1] = "asdfghjkl;";
  w[2] = "zxcvbnm,./";
  scanf("%s", dir);
  scanf("%s", s);
  for (int i = 0; s[i]; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < w[j].length(); k++) {
        if (w[j][k] == s[i]) {
          if (dir[0] == 'L') {
            putchar(w[j][k + 1]);
          } else {
            putchar(w[j][k - 1]);
          }
        }
      }
    }
  }
  putchar('\n');
  return 0;
}


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

int main() {
	string st;
	int n, i,wa,j;
	cin >> n;
	//scanf("%s", st);
	cin >> st;
	i = 0;
	j = 0;
	wa = 1;
	for (i = 1; i <= n / 2; i++) {
		if (st.substr(0, i) == st.substr(i, i))wa = i;
	}
	//while ((st.substr(i, j+1)==st.substr(j + 1, j+1)))j++;
	cout << n - wa+1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
long long n,dem=0;
int main()
{cin>>n;
cout<<n/2+1;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0);

  int k, a, cnt = 0, sum = 0;
  cin >> k;
  vector<int> v;
  while (cin >> a)
    v.push_back(a);
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < 12; i++)
  {
    if (sum >= k)
      break;
    sum += v[i];
    cnt++;
  }
  if (sum < k)
    cout << -1 << '\n';
  else
    cout << cnt << '\n';

  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_N=100005;

struct Fly
{
    int x,y;
}F[MAX_N];

struct Land
{
    int a,b;
}L[MAX_N];

int main()
{
    int R,B;
    cin>>R>>B;
    for(int i=0;i<R;i++)
    {
        cin>>F[i].x>>F[i].y;
    }
    for(int j=0;j<B;j++)
    {
        cin>>L[j].a>>L[j].b;
    }
    if(R==B)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <string>
#define sqr(x) (x)*(x)
#define fi first
#define se second
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=int(1e9+7);
int n,m;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif //ONLINE_JUDGE
    scanf("%d%d",&n,&m);

    for (int i=0; ; i++){
        if (i/2>=n && i/3>=m && i/2+i/3-i/6>=n+m){
            printf("%d",i);
            break;
        }
    }

    #ifndef ONLINE_JUDGE
    fclose(stdin);
    fclose(stdout);
    #endif // ONLINE_JUDGE
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[4];
    int sum=0;
    for(int i=0; i<4 ; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        sum/=2;
        sort(a,a+4);
        if(a[0]+a[3]==sum||a[3]==sum)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define y second
#define x first
#define NN 200100
#define mod 1000000007

using namespace std;
using INT=long long;
using VI=vector<int>;
using pii=pair<int, int>;
template<typename A, typename B> void smin(A &a, const B &b) {if(a>b) a=b;}
template<typename A, typename B> void smax(A &a, const B &b) {if(a<b) a=b;}

int fac[NN], rev[NN];

int power(int a, int b, int m, int ans=1) {
	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;
	return ans;
}

void pre() {
	fac[0]=1;
	rev[NN - 1] = power(NN - 1, mod - 2, mod);
	for(int i=1; i<NN; i++) fac[i] = (INT)fac[i-1] * i % mod;
	for(int i = NN - 2; i >= 0; i--) rev[i] = (INT)rev[i+1] * (i + 1) % mod;
}

int _C(int n, int k) {
	if(n<k) return 0;
	return (INT)fac[n]*rev[k]%mod*rev[n-k]%mod;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	pre();
	int f, w, h;
	scanf("%d%d%d", &f, &w, &h);
	if(w == 0){
		puts("1");
		return 0;
	}
	int tot = 0, ans = 0;
	for(int i = 1; i <= min(w, f+1); i++) {
		int t = (INT)_C(w-1, i-1)*_C(f+1, i) % mod;
		tot = (tot + t) % mod;
		if(w >= (INT)h * i) {
			int tmp = (INT)_C(w-i*h-1, i-1) * _C(f+1, i)%mod;
			ans = (ans + tmp) % mod;
		}
	}
	tot = power(tot, mod - 2, mod);
	ans = (INT)ans * tot % mod;
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10,p=1e9+7;
long long fpow(long long a,long long b){
    long long ans=1;
    for(;b;b>>=1,a=a*a%p)
        if(b&1)
            ans=ans*a%p;
    return ans;
}
long long kdm[N],m,k,n,jc[N],inv[N],ans=0;
long long P(long long a,long long b){
    return jc[b]*inv[b-a]%p;
}
void mzh(long long x){
    long long ret=1,tmp,d,e;
    if(2*n>x){
        if(x-n>k)
            return ;
        ret=fpow(k,2*n-x);
        d=(x-n)*P(x-n-1,k-1)%p;
        tmp=d*P(x-n,k)%p*2;
        tmp=(tmp-d*d%p)%p;
        ans=(ans+ret*tmp%p)%p;//printf("%d\n",ret*tmp);
    }
    else{
        if(n>k-x+2*n||x-2*n>k)
            return ;
        ret=P(x-2*n,k)*(k-x+2*n)%p;
        d=P(n-1,k-x+2*n-1);
        e=P(n-2,k-x+2*n-2)*(n-1)%p;
        tmp=e*2*d%p-e*e%p;
        tmp=tmp*(k-x+2*n-1)%p+d*d%p;
        ans=(ans+ret*tmp%p)%p;//printf("%d\n",ret*tmp);
    }
}
int main(){
    scanf("%lld%lld",&k,&n);
    m=n+k;
    kdm[0]=1;
    for(int i=1;i<=k;i++)
        kdm[i]=kdm[i-1]*k%p;
    jc[0]=1;
    for(int i=1;i<=k;i++)
        jc[i]=jc[i-1]*i%p;
    inv[k]=fpow(jc[k],p-2);
    for(int i=k-1;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%p;
    for(int i=n+1;i<=m;i++){
        mzh(i);
    }
    printf("%lld",(ans%p+p)%p);
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int a, cont = 0, aux = -1;
    vector<int> num;
    for (int i = 0; i < 4; i++) {
        cin >> a;
        num.push_back(a);
    }

    for(int j=0; j < num.size() - 1; j++) {
        for(int x = 3; x >= 0; x--) {
            if (num[j] == num[x] && j != x && x != aux && j!= aux){
                aux = x;
                cont++;
            }

        }
    }
    if (cont == 0 || cont == 1){
        cout << cont << endl;
    }

    else if (cont < 5){
        cout << 2 << endl;
    }

    else {
        cout << 3 << endl;
    }

    return 0;
}
// 1536381269039


#include<bits/stdc++.h>
using namespace std;
const int MAXN=4e6+5;
int n,m;
int dp[MAXN];
int sum[MAXN];
int main(){
	scanf("%d %d",&n,&m);
	dp[n]=1;
	sum[n]=1;
	for(int i=n-1;i>=1;i--)
	{
		dp[i]=sum[i+1];

		for(int j=2;j*i<=n;j++)
		{
			dp[i]+=(sum[j*i]-sum[min(n,((j)*(i+1))-1)+1]+m)%m;
	//		printf("%d %d\n",min(n,((j)*(i+1))-1),j*i-1);
			dp[i]%=m;
		}
		sum[i]=sum[i+1]+dp[i];
		sum[i]%=m;
	 }
	 printf("%d",dp[1]);
}


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

using namespace std;

int main()
{
	int i,j,n_zcy;
	long long int zcy[100000], n_ints, mod_val=1, total=0;
	string temp, temp2;

	cin >> n_ints >> mod_val;

	for (int i=1; n_zcy < n_ints; i++) {
		temp = temp2 = to_string(i);

		for (int j=temp.length()-1; j>=0; j--) {
			temp2[j] = temp[temp.length()-1-j];
		}

		zcy[i-1] = stoll(temp+temp2);
		n_zcy++;
	}

	for (int i=0; i<n_ints; i++) {
	    total += zcy[i];
	    //cout << zcy[i] << " " << to_string(zcy[i]).length() << endl;
	}

	cout << total % mod_val;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lr(a) memset(a,0,sizeof(a))
const int N=550,mod=998244353;
int n,x,C[N][N],pw[N][N]; //组合数&幂
int dp[N][N],ans; //dp[n][x]
void init(){
	lr(dp),lr(pw),lr(C);
	for(int i=0;i<=510;i++)C[i][0]=pw[i][0]=1;         //还有这里！i要从0开始，不然C[n][n]就等于0鸟QWQWQWQ
	for(int i=1;i<=510;i++)
	for(int j=1;j<=510;j++)
		C[i][j]=(C[i-1][j-1]+C[i-1][j]+mod)%mod,
		pw[i][j]=(pw[i][j-1]*i+mod)%mod;
	scanf("%lld%lld",&n,&x);
}
int solve(){
	for(int peo=2;peo<=n;peo++){
		for(int i=1;i<=x;i++){
			if(i<=peo-1)dp[peo][i]=(pw[i][peo]-pw[i-1][peo]+mod)%mod;   //错在这里了！ i和peo刚开始写反了!qwq
			else{
				for(int k=2;k<=peo;k++){
					dp[peo][i]=(dp[peo][i]+dp[k][i-(peo-1)]%mod*C[peo][k]%mod*pw[peo-1][peo-k]+mod)%mod;
				}
			}
		}
	}
	for(int maxn=1;maxn<=x;maxn++){
		ans=(ans+dp[n][maxn]+mod)%mod;
	}
	return ans;
}
signed main(){
	init();
	printf("%lld\n",solve());
}


#include <iostream>
#include <algorithm>
#include <sstream>

using namespace std;

int main()
{
    string n;
    stringstream ss;
    int num;

    cin >> n;
    ss << n;
    ss >> num;
    if (num >= 0)
        cout << num << endl;
    else if (n.size() == 3 && n[2] == '0')
        cout << 0 << endl;
    else {
        int min_ans = num;
        int st;

        for (int i = n.size() - 2; i < n.size(); i++) {
            stringstream sst;
            int tmp;

            sst << n.substr(0, i) + n.substr(i + 1, n.size() - i - 1);
            sst >> tmp;
            min_ans = max(min_ans, tmp);
        }
        cout << min_ans << endl;
    }

    return 0;
}


/* Easy problem but I'm just trying to solve it with 0(1) complexity */

#include "bits/stdc++.h"
using namespace std;
typedef  long long ll ;
typedef vector<int> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(int i = a ; i< b ; ++i)
#define repp(i,a,b) for(i = a ; i< b ; ++i)
#define reppp(i,a) for( ll i = a ; i >= 0 ; --i)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve   vec ,   vec2  , vec3  , vec4 , v , p;
int t , n , m , k ;
ll    sum , cnt , ans;
map<int,vector<int>> graph ;
vector<ve> sv ;
vector<bool>visited ;
queue<char> pq , pq2 ;
map< ll , ll> mp ,  mpp ,mpc ;
bool sortBy(pair <ll , ll> &a,pair <ll , ll>  &b)
{
    return a.second > b.second;

}
ll power(ll x, unsigned long long int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
const int sss = 1e6+1 ;
const int sss2 = 1e5+2 ;
int gcd (int a  , int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int x = 0  , y =  0 ;
void substrPosition(string str, string sub_str) {
    for (int i = 0; i < str.length(); i++) {
        if (str.substr(i, sub_str.length()) == sub_str) {
            if (cnt == 0 ) { x = i+1 ; y =i+2 ;}
            else {
                y = i+2 ;
            }
            cnt++ ;
        }
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
  string s1 ,s2 , s3 ;
  cin >> s1 >> s2 >> s3 ;

    vector<string> ok ;
    ok.PB(s1) ;   ok.PB(s2) ;  ok.PB(s3) ;
    sort(ok.begin() , ok.end()) ;
    if (ok[0]==ok[1] && ok[1]==ok[2]) {
        cout << "0\n" ;
        return 0 ;
    }
    int f = ok[0][0] - '0' ;
    int s = ok[1][0] - '0';
    int tt = ok[2][0] - '0' ;
    if (f+1 == s && s+1==tt && s1[1] == s2[1] && s3[1] == s2[1]){
        cout << "0\n" ;
        return 0 ;
    }
    cnt = 0 ;
    rep( i , 0 , ok.size()-1){
        if ((ok[i][0]-'0')+1 == (ok[i+1][0]-'0') && ok[i][1]==ok[i+1][1]){
            cnt = 1 ;
            break ;
        }
        if ((ok[i][0]-'0')+1 == (ok[2][0]-'0') && ok[i][1]==ok[2][1]){
            cnt = 1 ;
            break ;
        }
        if (ok[i] == ok[i+1]){
            cnt = 1 ;
            break ;
            }
        if (ok[i] == ok[2]){
            cnt =1 ;
            break ;
        }
        if ((ok[i][0]-'0')+2 == (ok[i+1][0]-'0') && ok[i][1] == ok[i+1][1])
        {  cnt = 1 ; break ; }
        if ((ok[i][0]-'0')+2 == (ok[2][0]-'0') && ok[2][1]==ok[i][1] && i ==0 )
        {  cnt = 1 ; break ; }
        cnt =2 ;

    }
    cout << cnt <<endl ;
}


#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[101];
int n;
int f(int z, int i, int j){
	int m = 0;
	if(s[i]==s[j]){
		m = max(m, 1+f(z+1, i+1, j+1));
	}
	return m;
}
int main(){
	gets(s);
	n = strlen(s);
	int m = 0;
	for(int i = 0; i < n; i ++)for(int j = i+1; j < n; j ++){
		m = max(m, f(0, i, j));
	}
	printf("%d\n", m);
	return 0;
}


// AUTHOR - RUTVIK KOTHARI
// DAIICT , GANDHINAGAR

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e6 + 5;
const ll M = 1e3 + 5;
const ll mod = 1e9 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

bool vi[N];

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll m,a,b;
    cin>>m>>a>>b;

    ll g = gcd(a,b);
    ll l = lcm(a,b);

    ll ans = 0;
    ll lim = 0;

    set <ll> rem;
    ordered_set tmp;

    rem.insert(0);
    tmp.insert(0);
    ll num = a+b;

    if(m>num)
    {
        ll k = (m-num)/g;

        ll x1 = k;
        ll x2 = num/g + 1;
        ll x3 = k-1;

        ans = (x1*g*x2) + (g*((x3*(x3+1))/2));
        //cout<<x1<<"  "<<ans<<"\n";
        for(i=0;i<=(m%g);i++)
        {
            ans += (m-i)/g + 1;
        }
        //cout<<ans<<"\n";

        while(lim<num)
        {
            while(rem.size()!=0 && *(rem.begin())<=lim)
            {
                ll p = *(rem.begin());
                rem.erase(p);

                if(p+a<=num && tmp.find(p+a)==tmp.end())
                {
                    rem.insert(p+a);
                    tmp.insert(p+a);
                }
                if(p-b>0 && tmp.find(p-b)==tmp.end())
                {
                    rem.insert(p-b);
                    tmp.insert(p-b);
                }
            }
            ans += tmp.order_of_key(lim+1);

            //cout<<lim<<"  "<<tmp.order_of_key(lim+1)<<"\n";
            lim++;
        }
    }
    else
    {
        while(lim<m+1)
        {
            while(rem.size()!=0 && *(rem.begin())<=lim)
            {
                ll p = *(rem.begin());
                rem.erase(p);

                if(p+a<=m && tmp.find(p+a)==tmp.end())
                {
                    rem.insert(p+a);
                    tmp.insert(p+a);
                }
                if(p-b>0 && tmp.find(p-b)==tmp.end())
                {
                    rem.insert(p-b);
                    tmp.insert(p-b);
                }
            }
            ans += tmp.order_of_key(lim+1);
            lim++;
        }
    }

    cout<<ans;

    return 0;
}


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

int main()
{
    vector <ll> v;
    ll count=0;
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            v.push_back(i);
            if(i*i!=n){
            v.push_back(n/i);}
            count=count+2;
        }
    }
    sort(v.begin(),v.end());
    ll len=v.size();

    if(k>n){
        cout<<"-1";
        return 0;
    }
    if(v.size()>=k){
        cout<<v[k-1];
        return 0;
    }
    else{
        cout<<"-1";
        return 0;
    }

}


#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...)
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 1000010

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int f[N],inv[N],dp[N];
int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int j,i,k,T,ca=0,K=0,n,m;
    scanf("%d%d",&n,&K);
    f[0]=1;
    rep(i,1,n+1)f[i]=1LL*f[i-1]*i%mod;
    inv[n]=pow(f[n],mod-2);
    per(i,0,n)inv[i]=1LL*inv[i+1]*(i+1)%mod;
    dp[0]=1;
    rep(i,1,n+1){
        m=dp[i-1];
        if(i>K)m=(m-dp[i-1-K]+mod)%mod;
        m=1LL*f[i-1]*m%mod;
        dp[i]=(dp[i-1]+1LL*inv[i]*m)%mod;
    }
    ll ans=(f[n]-1LL*dp[n-1]*f[n-1])%mod;;
    if(ans<0)ans+=mod;
    printf("%d\n",ans);
    return 0;
}


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

vector<int> V;
int ma[100];
int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < m;++i){
		int a;
		cin >> a;
		ma[a - 1]++;
	}
	int ans = 0;
	int ans2 = 0;
	for(int i = 1;i <= m;i++){
		ans = 0;
		for(int j = 0;j < 100;++j){
			ans = ans + ma[j] / i;
		}
		//cout << ans;
		if(ans >= n) ans2 = i;
	}
	cout << ans2;
	return 0;
}


#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int x, y;
int main()
{
	cin >> x >> y;
	if (y == 1)
		if(x==0) { cout << "yes"; return 0; }
		else { cout << "no"; return 0; }
	if (y > 1 && (x - y + 1) % 2 == 0 && (x - y + 1) >= 0) cout << "yes";
	else cout << "no";
}


#include <iostream>
using namespace std;
string s;
int k,i;
main(){
    cin>>i>>s;
    for (i=0; i<s.size();i++) if (s[i]=='0') k++;
    if(k!=s.size()) cout<<1;
    for (i=0; i<k; i++) cout<<0;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 5000005;
const int mod = 1e9 + 7;
const long long inf = 1000000000000000LL;
/*
int lp[N];
void Sieve(){
    for(int i = 2; i < N; ++i){
        if(lp[i] == 0){
            for(int k = i; k < N; k+=i){
                if(!lp[k]){
                    lp[k] = i;
                }
            }
        }
    }
}

vector<int> D[N];

vector< pair<int,int> > descomposition[N];

int current;
void getDivisors(int pos,int val){
    if(pos == descomposition[current].size()){
        D[current].push_back(val);
        return;
    }

    for(int i = 0; i <= descomposition[current][pos].second; i++){
        getDivisors(pos+1,val);
        val *= descomposition[current][pos].first;
    }
}

void Solve(int x){

    current = x;
    int lastprime = lp[x];
    int c = 0;
    while(x > 1){
        if(lastprime != lp[x]){
            descomposition[current].push_back({lastprime , c});
            lastprime = lp[x];
            c = 1;
        }else{
            c++;
        }
        x/=lp[x];
    }

    descomposition[current].push_back({lastprime,c});
    getDivisors(0,1);
}
*/

long long f[N];

int main(){

   // freopen("in.c","r",stdin);

  //  Sieve();

  /*  for(int x = 1; x < N; ++x){
        Solve(x);
    }
*/
    for(int i = 1; i < N; ++i){
        f[i] = inf;
    }

    f[1] = 0;
    for(int x = 1; x < N; x++){
        for(int n = x ,g = 1; n < N; n+=x , g++){
            f[n] = min(f[n] , (long long)x * (long long)g * (g - 1) / 2  + f[x]);
        }
    }

    int answer = 0;
    int l , r , t;
    scanf("%d %d %d",&t,&l,&r);
    int newt = 1;
    for(int i = l; i <= r; ++i){
        answer += newt * (f[i] % mod)  % mod;
        if(answer >= mod){
            answer -= mod;
        }
        newt = (long long) newt *  t % mod;;
    }
    cout << answer << endl;

    return 0;
 }


// Codeforces.com - Problem 124A
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
using namespace std;
int main(int argc, char *argv[])
{
    unsigned short n,a,b;
    cin>>n>>a>>b;
    n = n - a;
    if(b >= n)
        cout<<n;
    else
        cout<<b+1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[10000];
    int mx = 0;
    int i;
    int count = 0;
    int f;

    cin>>n;
    for(i = 0; i < n; i++) {
        cin>>a[i];
    }
    for(i = 1; i < n; i++) {
        if(a[i] > mx) {
            mx = a[i];
        }
    }
    int x;
    sort(a+1,a+n);
    reverse(a+1,a+n);
    /*for(i = 0; i < n; i++) {
        cout<<a[i]<<' ';
    }
    cout<<endl;*/
    if(mx == 0) {
        cout<<0;
        return 0;
    }
    int flag = 0;
    f = a[0];

    while(1) {
        mx = 0;
        for(i = 1; i < n; i++) {
            if(a[i] > mx) {
               mx = a[i];
               x = i;
            }
        }
        if(mx < f) {
            break;
        }
        else {
            f = f + 1;
            count++;
            a[x] = a[x] - 1;
        }
    }
 cout<<count;
}


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

const int MOD = 998244353;
const long long MULT = 1033;

struct chash {
    const int RANDOM = (long long)(make_unique<char>().get()) ^ chrono::high_resolution_clock::now().time_since_epoch().count();
    static unsigned long long hash_f(unsigned long long x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; }
    int operator()(int x) const { return hash_f(x)^RANDOM; }
};

int N;
int X, Y, X_MASK, Y_MASK;
vector<int> number;
unordered_map<long long, int, chash> save;
vector<pair<int, int>> options;

bool successful(int x_mask, int y_mask) {
    for (pair<int, int> p : options)
        if ((x_mask >> p.first & 1) != 0 && (y_mask >> p.second & 1) != 0)
            return true;

    return false;
}

// compare: 0 means less, 1 means equal, 2 means greater
long long solve(int index, int x_mask, int y_mask, int x_carry, int y_carry, int y_compare) {
    bool success = successful(x_mask, y_mask);

    if (success) {
        // If successful, we no longer care about the specific values of these masks.
        x_mask = 1 << options.front().first;
        y_mask = 1 << options.front().second;
    }

    if (index == N) {
        if (y_compare > 1 || y_carry > 0)
            return 0;

        return success ? 1 : 0;
    }

    long long hash = index;
    hash = MULT * hash + x_mask;
    hash = MULT * hash + y_mask;
    hash = MULT * hash + x_carry;
    hash = MULT * hash + y_carry;
    hash = MULT * hash + y_compare;

    if (save.find(hash) != save.end())
        return save[hash];

    long long sum = 0;

    for (int d = 0; d <= 9; d++) {
        int x_add = X * d + x_carry;
        int y_add = Y * d + y_carry;
        int x_digit = x_add % 10;
        int y_digit = y_add % 10;
        int new_x_carry = x_add / 10;
        int new_y_carry = y_add / 10;
        int new_x_mask = x_mask | (X_MASK & 1 << x_digit);
        int new_y_mask = y_mask | (Y_MASK & 1 << y_digit);
        int new_y_compare = y_compare;

        if (y_digit > number[index])
            new_y_compare = 2;
        else if (y_digit < number[index])
            new_y_compare = 0;

        sum += solve(index + 1, new_x_mask, new_y_mask, new_x_carry, new_y_carry, new_y_compare);
    }

    return save[hash] = sum % MOD;
}

int main() {
    string str;
    cin >> str;
    N = str.size();

    for (int i = 0; i < N; i++)
        number.push_back(str[i] - '0');

    reverse(number.begin(), number.end());
    long long answer = 0;

    for (X = 1; X <= 9; X++)
        for (Y = X; Y <= 9; Y++)
            if (__gcd(X, Y) == 1) {
                options = {};
                X_MASK = Y_MASK = 0;

                for (int k = 1; k * Y <= 9; k++) {
                    options.emplace_back(k * X, k * Y);
                    X_MASK |= 1 << (k * X);
                    Y_MASK |= 1 << (k * Y);
                }

                save = {};
                answer = (answer + (X < Y ? 2 : 1) * solve(0, 0, 0, 0, 0, 1)) % MOD;
            }

    answer = (answer % MOD + MOD) % MOD;
    cout << answer << '\n';
}


#include<bits/stdc++.h>
using namespace std;
using std::string;
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define FORR(i,l,r) for(int (i)=l;(i)<(r);++(i))
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define EPSILON 1e-9
#define MAX 100002
#define PI 3.1415926535897932384626433832795028841971693993751
typedef long long  ll;
typedef unsigned long long llu;
typedef long double  ldb;
typedef double  db ;
vector<ll>v;
int main()
{
   // freopen("in.txt","r",stdin);
    ll ans=0;
    ll l,r,x,y;
    scanf("%lld%lld%lld%lld",&l,&r,&x,&y);
    ll prod=y*x;
    for(ll i=1;i*i<=y;i++)
    {
        if(y%i)
            continue;
        else
        {
             v.pb(i);
             if(y/i!=i)
               {
                    v.pb(y/i);
                ;
               }
        }
    }
        FOR(i,v.size())
        {
            FOR(j,v.size())
            {
                if(v[i]<=r&&v[i]>=l&&v[j]<=r&&v[j]>=l&&__gcd(v[i],v[j])==x&&(v[i]*v[j])/__gcd(v[i],v[j])==y)
                 {
                                       ans++;
                 }
            }
        }

    printf("%lld",ans);
}


#include <bits/stdc++.h>
#include <map>
#include <iterator>
#include <cstdlib>
#include <bits/stdc++.h>

using namespace std;

int main() {
int s , v1 ,v2 ,t1 , t2 ;
cin >> s >> v1 >> v2 >> t1 >> t2;

int a1 = (s * v1 )+ (t1 * 2);

int a2 = (s * v2) + (t2 * 2) ;

if (a1 < a2)

cout << "First";

else if (a1 > a2) cout << "Second" ;

else cout << "Friendship" ;

;

return 0 ;}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cmath>

using namespace std;

const int N = 100001;

string s[4];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	for (int i = 0; i < 4; ++i)
		cin >> s[i];
	for (int i = 0; i < 4; ++i)
		s[i].erase(s[i].begin()), s[i].erase(s[i].begin());
	int cnt = 0, ans = 'A';
	for (int i = 0; i < 4; ++i)
	{
		bool flag = true;
		for (int j = 0; j < 4; ++j)
		{
			if (i == j)
				continue;
			if (2 * s[i].size() > s[j].size())
				flag = false;
		}
		if (flag == true)
		{
			cnt++;
			ans = 'A' + i;
		}
		flag = true;
		for (int j = 0; j < 4; ++j)
		{
			if (i == j)
				continue;
			if (s[i].size() < 2 * s[j].size())
				flag = false;
		}
		if (flag == true)
		{
			cnt++;
			ans = 'A' + i;
		}
	}
	if (cnt > 1 || cnt == 0)
		printf("C");
	else
		printf("%c", ans);

    return 0;
}


#include <iostream>

using namespace std;

int main(){
    short n, r, s = 0; string st;
    cin >> n >> st;
    if (st[0] == 'x') r = 1; else r = 0;
    for (int i = 1; i < n; i++){
        if (st[i] == 'x') r++; else{
            if (r > 2) s += r - 2;
            //cout << s << r << endl;
            r = 0;
        }
    }
    if (r > 2) s += r - 2;
    cout << s;
    return 0;
}


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

static char dd[2][13] = {
    {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};

int jd_year(int year)
{
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
        return 1;
    return 0;
}

int day_of_year(int year, int month, int day)  // 算出该日期在该year年处于第几天
{
    for (int i = 1; i < month; i++)
        day += dd[jd_year(year)][i];
    return day;
}

int main()
{
    int y, m, d, y1, m1, d1, i, cnt;
    scanf("%d:%d:%d", &y, &m, &d);
    scanf("%d:%d:%d", &y1, &m1, &d1);
    if (y > y1 || (y == y1 && m > m1) || (y == y1 && m == m1 && d > d1))
    {
        swap(y, y1);
        swap(m, m1);
        swap(d, d1);
    }
    if (y == y1)
    {
        if (m != m1)
        {
            cnt = dd[jd_year(y)][m]-d + d1;
            for (i = m+1; i < m1; i++)
                cnt += dd[jd_year(y)][i];
        }
        else
            cnt = d1 - d;
    }
    else
    {
        cnt = day_of_year(y, m, d);
        if (jd_year(y))
            cnt = 366 - cnt;
        else
            cnt = 365 - cnt;
        cnt += day_of_year(y1, m1, d1);
        for (i = y+1; i < y1; i++)
        {
            if (jd_year(i))
                cnt += 366;
            else
                cnt += 365;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


#include <bits/stdc++.h>

#define MN 5000500

using namespace std;
typedef long long ll;

vector<int> isp(MN);
vector<ll> primes, acum_pi(MN);

int phi_table[300000][100];
ll l, r, k, ans;

void crivo_super_modificado_3000_v2_beta() {
    for(int i=2; i<MN; i++) isp[i] = 1;
    for(int i=2; i<MN; i++) {
        if(isp[i]) {
            primes.push_back(i);
            for(int j=2*i; j<MN; j+=i)
                isp[j] = 0;
            }
        acum_pi[i] = acum_pi[i-1] + isp[i];
    }

    for(int i=0; i<300000; i++) {
        phi_table[i][0] = i;
        for(int k=1; k<100; k++) {
            phi_table[i][k] = phi_table[i][k-1] - phi_table[i/primes[k-1]][k-1];
        }
    }

}

ll pi_(ll x);

///Phi function
ll solve(ll n, ll k) {
    if(n < 300000 && k < 100) return phi_table[n][k];
    if(k == 0) return n;
    if(k > primes.size()) return pi_(n) - k + 1;
    if(primes[k - 1] > n) return 1;
    if(n < primes[k - 1] * primes[k - 1]) return pi_(n) - k + 1;
    return solve(n, k - 1) - solve(n/primes[k - 1], k - 1);
}

///Prime count up to X
ll pi_(ll x) {
    if(x < MN) return acum_pi[x];
    ll cubic_root = ceil(pow(x, 1./3));

    ll k = acum_pi[cubic_root];

    ll ret = solve(x, k) + k - 1;
    while(primes[k] * primes[k] <= x) {
        ret = ret - pi_(x / primes[k]) + k;
        k++;
    }
    return ret;
}

bool is_prime(ll x) {
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    if(x < 2) return false;

    for(int i=0; primes[i] * primes[i] <= x; i++) {
        if(x % primes[i] == 0) return false;
    }

    return true;
}

int main() {
    crivo_super_modificado_3000_v2_beta();
    scanf("%lld %lld %lld", &l, &r, &k);

    if(!is_prime(k)) {
        printf("0\n");
        return 0;
    }

    ll prime_idx = pi_(k);
    if(k <= r) ans = solve(r, prime_idx - 1) - solve(r, prime_idx);
    if(k < l) ans = ans - solve(l - 1, prime_idx - 1) + solve(l - 1, prime_idx);

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


#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >>s;
	int count = 0;
	for (int i = 0; i <=(s.size()-1) ; i++)
	{
		if (s[i] == '1')
			count++;
    }
	if (count == 0)
		cout << "0" << "\n";
	else if (count == 1)
		cout << s.size() / 2 << "\n";
	else
	{
		if (s.size() % 2 == 0)
			cout << s.size() / 2 << "\n";
		else
			cout << (s.size() / 2) + 1 << "\n";
	}
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
string a;
int main(){
    cin>>a;
    int n=a.length();
    int k=0;
    for(int i=0;i<n;i++){
        if(a[i]!='7' && a[i]!='4')
            k++;
    }
    if(k==n){
        cout<<"NO";
        return 0;
    }
    int f=n-k;
    while(f>=1){
        if((f-7)%10!=0 && (f-4)%10!=0){
            cout << "NO";
            return 0;
        }
        if((f-7)%10==0){
            f-=7 ;
            f/=10 ;
        }
        if((f-4)%10==0){
            f-=4 ;
            f/=10 ;
        }
    }
    cout<<"YES";
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int x,y;
        for(int i=0;i<5;i++)
        {
            for(int j=0;j<5;j++)
            {
                int z;
                cin>>z;
                if(z==1)
                {
                    x=i;
                    y=j;
                }
            }
        }
        int steps=abs(2-x) + abs(2-y);
        cout<<steps;
    }


#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;
int a[3][6];

bool is(int x, int in){

	for (int i=0; i<6; i++){
		if (a[in][i]==x) return true;
	}
	return false;
}

bool num(int x){
	bool pas=false;
	if (x<10){
		if (is(x,0) || is(x,1) || is(x,2)){
			return true;
		}
		else return false;
	}
	else{
		if (x<100){
			int k=x/10; int p=x%10;
			if (is(k,0) && is(p,1)) pas=true;
			if (is(k,0) && is(p,2)) pas=true;

			if (is(k,1) && is(p,0)) pas=true;
			if (is(k,1) && is(p,2)) pas=true;

			if (is(k,2) && is(p,1)) pas=true;
			if (is(k,2) && is(p,0)) pas=true;
			return pas;
		}
		else{
			int k=x/100; int p=(x-100*k)/10; int t=x%10;

			if (is(k,0) && is(p,1) && is(t,2)) pas=true;
			if (is(k,0) && is(p,2) && is(t,1)) pas=true;

			if (is(k,1) && is(p,0) && is(t,2)) pas=true;
			if (is(k,1) && is(p,2) && is(t,0)) pas=true;

			if (is(k,2) && is(p,1) && is(t,0)) pas=true;
			if (is(k,2) && is(p,0) && is(t,1)) pas=true;
			return pas;
		}
	}
	return pas;
}

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

	for (int i=0; i<n; i++){
		for (int j=0; j<6; j++){
			cin>>a[i][j];
		}
	}
	for (int i=2; i>=n; i--){
		for (int j=0; j<6; j++){
			a[i][j]=-1;
		}
	}

	for (int i=1; i<1000; i++){
		if (!num(i)) {
			ans=i-1;
			break;
		}
	}
	cout<<ans;

	//system("pause");
	//return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

struct matrix {
    int rows, cols, MOD;
    int **c;

    void init() {
        c = new int*[rows];
        for(int i = 0; i < rows; i++)
            c[i] = new int[cols];
    }
    void clean() {
        for(int i = 0; i < rows; i++)
            delete [] c[i];
        delete [] c;
    }

    int* operator [] (int row) {
        return c[row];
    }

    matrix(int row, int col, int M = 1000000007) : rows(row), cols(col), MOD(M) {
        init();
        for(int i = 0; i < rows; i++)
            memset(c[i], 0, cols * sizeof(int));
    }

    matrix(const matrix &o) : rows(o.rows), cols(o.cols), MOD(o.MOD) {
        init();
        for(int i = 0; i < rows; i++)
            memcpy(c[i], o.c[i], cols * sizeof(int));
    }

    matrix& operator = (const matrix &o) {
        clean();
        rows = o.rows; cols = o.cols; MOD = o.MOD;
        init();
        for(int i = 0; i < rows; i++)
            memcpy(c[i], o.c[i], cols * sizeof(int));
        return *this;
    }

    ~matrix() { clean(); }

    void print() {
        for(int i = 0; i < rows; i++) {
            for(int j = 0; j < cols; j++)
                printf("%d ", c[i][j]);
            puts("");
        }
    }

    matrix operator + (matrix b) const {
        assert(rows == b.rows && cols == b.cols);
        for(int i = 0; i < rows; i++)
            for(int j = 0; j < cols; j++) {
                b.c[i][j] += c[i][j];
                if(b.c[i][j] >= MOD) b.c[i][j] -= MOD;
            }
        return b;
    }

    matrix operator - (matrix b) const {
        assert(rows == b.rows && cols == b.cols);
        matrix ret = *this;
        for(int i = 0; i < rows; i++)
            for(int j = 0; j < cols; j++) {
                ret.c[i][j] -= b.c[i][j];
                if(ret.c[i][j] < 0) ret.c[i][j] += MOD;
            }
        return ret;
    }

    matrix operator * (ll k) const {
        matrix ret = *this;
        k %= MOD;
        for(int i = 0; i < rows; i++)
            for(int j = 0; j < cols; j++)
                ret.c[i][j] = (1LL * ret.c[i][j] * k) % MOD;
        return ret;
    }

    matrix operator % (matrix b) const {
        assert(cols == b.rows);
        matrix ret(rows, b.cols, MOD);
        ll MOD2 = 1LL * MOD * MOD;
        for(int i = 0; i < rows; i++) {
            for(int j = 0; j < b.cols; j++) {
                ll sum = 0;
                for(int k = 0; k < cols; k++) {
                    sum += (1LL * c[i][k] * b.c[k][j]);
                    if(sum >= MOD2) sum -= MOD2;
                }
                ret.c[i][j] = sum % MOD;
            }
        }
        return ret;
    }

    matrix operator ^ (ll exp) const { //matrix^0 = identity
        matrix ret = matrix(rows, cols, MOD), base = *this;
        for(int i = 0; i < rows; i++) ret.c[i][i] = 1;

        while(exp) {
            if(exp & 1) ret = ret % base;
            exp >>= 1;
            if(exp) base = base % base;
        }
        return ret;
    }
};

const ll MOD = 1000000007;
ll n, k, coef[50][50], ii[50], ifi[50], if1[50], cnt = 3, SZ = 130;
vector<pair<int, int>> c[220];

int main() {
    scanf("%lld %lld", &n, &k);
    if(n < 3) {
        if(n == 1) puts("1");
        if(n == 2) printf("%lld\n", (1LL + (2LL << k)) % MOD);
        return 0;
    }

    coef[0][0] = 1;
    for(int i = 1; i <= k; i++) {
        coef[i][0] = coef[i][i] = 1;
        for(int j = 1; j < i; j++)
            coef[i][j] = (coef[i-1][j] + coef[i-1][j-1]) % MOD;
    }

    for(int i = 0; i <= k; i++) ii[i] = cnt++;
    for(int i = 0; i <= k; i++) ifi[i] = cnt++;
    for(int i = 0; i <= k; i++) if1[i] = cnt++;

    matrix mat(SZ, SZ);
    for(int j = 0; j <= k; j++) {
        if(j == 0) mat[ii[j]][ii[j]] = 1;
        else for(int p = 0; p <= k; p++) {
            mat[ii[j]][ii[p]] = coef[j][p];
        }
    }
    for(int j = 0; j <= k; j++) {
        if(j == 0) {
            mat[ifi[j]][ifi[j]] = 1;
            mat[ifi[j]][if1[j]] = 1;
        }
        else for(int p = 0; p <= k; p++) {
            mat[ifi[j]][ifi[p]] = coef[j][p];
            mat[ifi[j]][if1[p]] = coef[j][p];
        }
    }
    for(int j = 0; j <= k; j++) {
        if(j == 0) {
            mat[if1[j]][ifi[j]] = 1;
        }
        else for(int p = 0; p <= k; p++) {
            mat[if1[j]][ifi[p]] = coef[j][p];
        }
    }

    mat[0][0] = 1;
    for(int p = 0; p <= k; p++) {
        mat[0][ifi[p]] = coef[k][p];
        mat[0][if1[p]] = coef[k][p];
    }

    matrix col(SZ, 1);
    col[0][0] = (1LL + (2LL << k)) % MOD;
    for(int j = 0; j <= k; j++) {
        col[ii[j]][0] = (1LL << j) % MOD;
    }
    for(int j = 0; j <= k; j++) {
        col[ifi[j]][0] = (2LL << j) % MOD;
    }
    for(int j = 0; j <= k; j++) {
        col[if1[j]][0] = (1LL << j) % MOD;
    }

    matrix res = (mat ^ (n - 2)) % col;
    printf("%d\n", res[0][0]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define                   vi vector<ll>
#define                   vpi vector<pair<ll,ll> >
#define                   mpi map<ll,ll>
#define                   si set<ll>
#define                   pq prority_queue<ll>
#define                   pqi  priority_queue<pair<ll, ll> >
#define                   rep(i,a,n) for(ll i=a;i<n;i++)
#define                   reP(i,a,n) for(ll i=a;i<=n;i++)
#define                   YES cout<<"YES\n";
#define                   NO cout<<"NO\n";
#define                   mp make_pair
#define                   pb push_back
#define                   fi first
#define                   se second
#define                   st string
#define                   sz size()
#define                   case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define                   tc ll t;cin>>t;while(t--)
priority_queue<ll,vector<ll>,greater<ll> > q;
int main()
{
    ll n,x,y;cin>>n>>x>>y;
    n/=2;
    if((x==n || x==n+1) &&(y==n || y==n+1))
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
}


#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<ctime>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout)

using namespace std;

#define pb push_back
#define pf push_front
#define p_f pop_front
#define p_b pop_back
#define LL __int64
#define LD long double
#define MP make_pair
#define fi first
#define se second
#define sc scanf
#define pr printf
#define str strlen
LL b,i,j,k,n,m,ans=0,c[1000001];
LL a,cnt=0,fl=0,a2,a3=-1000000,i1,l=0,r=0,gh=0,used[1000001]={0};
deque<LL>deq,deq2;
string s;
main()
{
    sc("%I64d",&n);
    for(i=1;i<=n;i++)
    {
        c[i]=i;
        used[1]=1;
    }
    cnt=1000000;
    i=1;
    r=1;
    gh=1;
    while(cnt>0)
    {
        if( used[i]==0 ){ used[i]=1;gh++; }
        if( gh==n ){ cout<<"YES\n";return 0; }
        i+=r;
        r++;
        i%=n;
        if( i==0 )i==1;
        cnt--;
    }
    cout<<"NO\n";
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<string.h>
#include<map>
#include<stdlib.h>
#include<cmath>
#include<malloc.h>
#include<queue>
#include<stack>
#include<climits>
#include<stdlib.h>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        bool sport=0,cont=0,special=0;
        int cnt=0,remind=-1,skip=0;;
        int num[105];
        memset(num,-1,sizeof(num));
        for(int i=0; i<n; i++)
            scanf("%d",&num[i]);
        for(int i=0; i<n; i++)
        {
            if(num[i]==0)
            {
                cnt++;
                cont=0;
                sport=0;
                continue;
            }
            if(num[i]==1)
            {
                if(cont)
                {
                    cnt++,cont=0;
                    continue;
                }
                else
                {
                    cont=1;
                    sport=0;
                    continue;
                }
            }

            if(num[i]==2)
            {
                if(sport)
                {
                    cnt++,sport=0;
                    continue;
                }
                else
                {
                    sport=1;
                    cont=0;
                    continue;
                }
            }
            if(num[i]==3)
            {
                if(sport)
                {
                    cont=1,sport=0;
                    continue;
                }
                if(cont)
                {
                    sport=1,cont=0;
                    continue;
                }
                while(num[i]==3)i++;
                i--;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
const int INF = 1e9;

int fun(int x)
{
  x++;
  while(!(x%10))
  {
    x /= 10;
  }
  return x;
}

int main()
{
#ifdef MY_DEBUG
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif
  int n = 0;
  cin >> n;
  set<int> s;
  s.insert(n);
  while(true)
  {
    n = fun(n);
    auto it = s.insert(n);
    if(!it.second)
      break;
  }
  cout << s.size();

  return 0;
}


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

const int N = 1e5 + 5;

int n, a[N], cnt;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i)
        if (a[i] == a[1]) ++cnt;
    if (cnt <= n >> 1) return cout << "Alice", 0;
    cout << "Bob";

}


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

long long dps[1000006];
long long dpn[1000006];
int inc = 300001;
long long mod = 1000000007ll;

int main(){
    int a, b, k, t; scanf("%d %d %d %d",&a,&b,&k,&t);
    dpn[a - b + inc] = 1ll;
    t *= 2;

    for(int i = 1;i <= t; i++){
        for(int j = 0;j <= inc + inc; j++){
            dps[j] = dpn[j];
            dpn[j] = 0;
        }
        for(int j = -inc;j <= inc; j++){
            if(!dps[j + inc]) continue;
            /*dp[c][j + inc - k] += dp[d][j + inc];
            dp[c][j + inc - k] %= mod;

            dp[c][j + inc + k + 1] += mod - dp[d][j + inc];
            dp[c][j + inc + k + 1] %= mod;*/

            dpn[j + inc - k] += dps[j + inc];
            if(dpn[j + inc - k] >= mod) dpn[j + inc - k] -= mod;

            dpn[j + inc + k + 1] += mod - dps[j + inc];
            if(dpn[j + inc + 1 + k] >= mod) dpn[j + inc + k + 1] -= mod;
        }

        for(int j = -inc + 1;j <= inc; j++){
            //dp[c][j + inc] += dp[c][j + inc - 1];
            //dp[c][j + inc] %= mod;

            dpn[j + inc] += dpn[j + inc - 1];
            if(dpn[j + inc] >= mod) dpn[j + inc] -= mod;
        }
    }

    long long ans = 0;
    for(int i = 1;i <= inc; i++){
        //ans += dp[t % 2][i + inc];
        ans += dpn[i + inc];
        if(ans >= mod) ans -= mod;
    }

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


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

const int MOD = 1000000007;
int f[5555][5555];
char a[5555];
char b[5555];
int n;
int m;

int main(void)
{
    cin >> a+1 >> b+1;
    n = strlen(a+1);
    m = strlen(b+1);
    int ans = 0;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            f[i][j] = f[i][j-1];
            if (a[i] == b[j])
            {
                f[i][j] += f[i-1][j-1];
                f[i][j]++;
                if (f[i][j] >= MOD) f[i][j] -= MOD;
            }
        }
        ans += f[i][m];
        if (ans >= MOD) ans -= MOD;
    }
    cout << ans << "\n";
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
	char a;int b=0,w=0;
	for(int i=1;i<=64;i++)
	{
		cin>>a;
		if(a=='Q') w+=9;
		if(a=='R') w+=5;
		if(a=='B') w+=3;
		if(a=='N') w+=3;
		if(a=='P') w+=1;

		if(a=='q') b+=9;
		if(a=='r') b+=5;
		if(a=='b') b+=3;
		if(a=='n') b+=3;
		if(a=='p') b+=1;
	}
	if(w>b) cout<<"White";
	else if(w<b) cout<<"Black";
	else cout<<"Draw";
	return 0;
}


//#include <ext/pb_ds/assoc_container.hpp>
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
 //mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); //for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)
map<int,int> m,m1;
vector<int> v;
int solve(int n)
{
    if(n==1)
        return 1;
    if(m1.find(n)!=m1.end())
        return m1[n];
    int ans=0;
    ans+=power(2,n-1)-1;
    ans+=mod;
    ans%=mod;
    for(auto i:v)
    {
        if(i>=n)
        break;
        if(n%i==0)
        {
            ans-=solve(n/i);
            ans+=mod;
            ans%=mod;
        }
    }
    m1[n]=ans;
    return ans;
}
int32_t main()
{
    IOS
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif

    int x,y;
    cin>>x>>y;
    if(y%x!=0)
    {
        cout<<0<<endl;
        return 0;
    }
    y/=x;
    for(int i=2;i<=sqrt(y);i++)
    {
        if(y%i==0)
        {
            v.push_back(i);
            if(i*i!=y)
            v.push_back(y/i);
        }
    }
    sort(v.begin(),v.end());
    cout<<solve(y);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
    for(int i=0;i<=n;i+=1234567)
		for(int j=0;j<=n-i;j+=123456)
			if ((n - i - j) % 1234 == 0)
			{
				printf("YES\n");
				return 0;;
			}
	printf("NO\n");

	return 0; }


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

int MaxHr, MaxMin, ans;
vector<int> hr, minute;

int ok(vector<int> X)
{
    int mask = 0;

    for(int i=0; i<X.size(); i++)
    {
        if((1<<X[i])&mask)
            return 0;

        mask += (1<<X[i]);
    }

    int h = 0, m = 0;

    for(int i=0; i<hr.size(); i++)
        h = h*10 + X[i];
    for(int i=0; i<minute.size(); i++)
        m = m*10 + X[i+hr.size()];

    if(h>MaxHr || m>MaxMin)
        return 0;

    return 1;
}

void solve(vector<int> X, int num)
{
    if(num==hr.size() + minute.size())
    {
        if(ok(X))
            ans++;

        return;
    }

    for(int i=0; i<7; i++)
    {
        vector<int> Y = X;
        Y.push_back(i);
        solve(Y, num+1);
    }
}

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

    N--, M--;

    if(N==0)
        hr.push_back(0);
    if(M==0)
        minute.push_back(0);

    while(N)
    {
        hr.push_back(N%7);
        N/= 7;
    }

    while(M)
    {
        minute.push_back(M%7);
        M/= 7;
    }

    reverse(hr.begin(), hr.end());
    reverse(minute.begin(), minute.end());

    for(int i=0; i<hr.size(); i++)
        MaxHr = MaxHr*10 + hr[i];
    for(int i=0; i<minute.size(); i++)
        MaxMin = MaxMin*10 + minute[i];

    if(hr.size()+minute.size()>7)
        cout << 0 << endl;
    else
    {
        vector<int> X;
        solve(X, 0);
        cout << ans << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb             push_back
#define fill(x, y)     memset(x, y, sizeof(x))
#define all(x)         (x).begin(), (x).end()
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define IO	       { ios_base::sync_with_stdio(false); cin.tie(0); }
#define read(x)	       freopen(x, "r", stdin)
#define write(x)       freopen(x, "w", stdout)

using namespace std;

typedef long long      ll;
typedef pair<int, int> ii;
typedef vector<int>    vi;
const ll mod = 1e9 + 7;
ll n, m, k, r, c;

ll bigmod(ll a, ll m) {
    if (m == 0) return 1LL;
    else if (m & 1) {
        return (a * bigmod(a, m-1)) % mod;
    } else {
        ll r = bigmod(a, m/2);
        return  (r*r) % mod;
    }
}

ii rt(ii p) {
    auto [x, y] = p;
    return {c - y + 1, x};
}
ii bt(ii p) {
    auto [x, y] = p;
    return {r - x + 1, c - y + 1};
}
ii bl(ii p) {
    auto [x, y] = p;
    return {y, r - x + 1};
}

ll get_int(ii a, ii b, int row, int col) {
    auto [x1, y1] = a;
    auto [x2, y2] = b;

    int x3 = x1 + row - 1, y3 = y1 + col - 1;
    if (x2 <= x3 and y2 <= y3 and x1 <= x2 and y1 <= y2) {
        return ((ll)(x3 - x2 + 1)) * ((ll)(y3 - y2 + 1));
    }
    return 0;
}

int main() {
    cin >> n >> m >> k >> r >> c;
    ll ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;

    // ll atx = ax, aty = ay + c - 1, btx = bx , bty = by + c - 1;

    // ll l1 = get_int({ax, ay}, {bx, by}, r , c);
    // ll l2 = get_int({bx, by}, {ax, ay}, r , c);

    // ii ac = rt({ax, ay}), bc = rt({bx, by});
    // ll l3 = get_int(ac, bc, c, r);
    // ll l4 = get_int(bc, ac, c, r);

    // ll intersect = max(max(l1, l2), max(l3, l4));

    ll squares = 0;
    if (ax == bx and ay == by) squares = n * m;
    else squares = n * m - r * c;

    cout << bigmod(k, squares) << endl;
}


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

int main()
{
int n,t,k,d;
cin>>n>>t>>k>>d;
int g=(n+k-1)/k;
if(g-(d/t)>1){
    cout<<"YES";
}
else{cout<<"NO";}
}


# include <iostream>
# include <cstdio>
# include <algorithm>
# include <cmath>
using namespace std;
int main()
{
	int n=0,all=0;
	double qaq=0.0;
	int m[17]={0},r[17]={0};
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>m[i];
	for(int i=0;i<n;i++)
		cin>>r[i];
	for(int i=1;i<=720720;i++)
		for(int j=0;j<n;j++)
			if(i%m[j]==r[j])
			{
				all++;
				break;
			}
	qaq=(double)all/720720;
	printf("%0.6lf",qaq);
	return 0;
}


//This code is solely the property of StarnyC

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()

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

int w,h,k;
cin>>w>>h>>k;

int m,i;
m=min(w,h);
int c=0;
for(i=0;i<k;i++)
{
	c+=2*(h+w)-4;
	if(m<0||k==1){cout<<c;break;}
	h=h-4;
	w=w-4;
	m=m-4;

}
if(i==k){cout<<c;}

}


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

int main()
{
    int space[10] = {0};
    int sticks[6];
    bool found = false;
    for(int i=0;i<6;i++)
    {
        cin>>sticks[i];
        space[sticks[i]]++;
    }
    //find legs
  bool legs = false,body=false,head = false, fourCondition = false;

  for(int i=0;i<10;i++)
  {
         if(space[i] == 6)
          {
              cout<<"Elephant\n";
              legs = true;
              found = true;
              break;
          }
        else if(space[i] == 5)
         {
          //its automatically bear right....
          cout<<"Bear\n";
          legs = true;
          found = true;
          break;
          }
     else if(space[i] == 4)
      {
          //legs found..
          //now two things can happen.....either the remaing sticks are of same length or different......
          //cout<<"gsdfhsfgfhs";
          legs = true;
          fourCondition = true;
          space[i] = 0;
          break;

      }
  }
  //check if legs are there or not...
  if(legs == false)
  {
      cout<<"Alien\n";
  }
  else
  {
      //legs are there, now we need to find if its a bear or an elephant....
      //cout<<"gdfg";
    if(fourCondition == true)
    {
        int body,head;
        bool b = false, h = false;
      for(int i=0;i<10;i++)
      {
         if(space[i] != 0)
         {
             body = i;
             //cout<<body;
             space[i]--;
             b = true;
             break;
         }
      }
      for(int i=0;i<10;i++)
      {
         if(space[i] != 0)
         {
             head = i;
             //cout<<head;
             space[i]--;
             h = true;
             break;
         }
      }
    if(h && b)
    {
      // cout<<head<<" "<<body;
        if(head == body)
        {
            //its an elephant...
            cout<<"Elephant\n";
        }
        else
        {
            cout<<"Bear\n";
        }

    }
    }

  }

}


#include <bits/stdc++.h>
using namespace std;
int A[81][81];
struct Edge{
	int to, cap, cost, next;
};
Edge E[30000];
int head[7000], ne = 1;
int NV;
inline void addEdge(int from, int to, int cap, int cost) {
	E[++ne] = {to, cap, cost, head[from]}, head[from] = ne;
	E[++ne] = {from, 0, -cost, head[to]}, head[to] = ne;
}
int d[7000], p[7000];
bool inqueue[7000];
pair<int, int> mcmf(int S, int T) {
	int f = 0, c = 0;
	while(1) {
		for(int i = 0; i < NV; ++i) d[i] = 1e9;
		queue<int> Q;
		Q.push(S); d[S] = 0;
		while(!Q.empty()) {
			auto v = Q.front(); Q.pop();
			inqueue[v] = 0;
			for(int x = head[v]; x; x = E[x].next) {
				int &u = E[x].to, &cap = E[x].cap, &cost = E[x].cost;
				if(cap > 0 and d[v] + cost < d[u]) {
					d[u] = d[v] + cost;
					p[u] = x;
					if(!inqueue[u]) Q.push(u), inqueue[u] = 1;
				}
			}
		}
		if(d[T] == 1e9) break;
		int df = 1e9;
		for(int i = T; i != S; i = E[p[i]^1].to)
			df = min(df, E[p[i]].cap);
		for(int i = T; i != S; i = E[p[i]^1].to)
			E[p[i]].cap -= df, E[p[i]^1].cap += df;
		f += df, c += df * d[T];
	}
	return {f, c};
}
int n, m;
inline int group(int i, int j) {
	return (i + j) & 1;
}
inline int id(int i, int j) {
	return (i-1)*m+j;
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			cin >> A[i][j];
	int S = 0, T = 6789;
	NV = 6790;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) {
			if(group(i, j) == 0)
				addEdge(S, id(i, j), 1, 0);
			else
				addEdge(id(i, j), T, 1, 0);
		}
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			if(group(i, j) == 0) {
				if(i-1 >= 1)
					addEdge(id(i, j), id(i-1, j), 1, A[i][j] != A[i-1][j]);
				if(i+1 <= n)
					addEdge(id(i, j), id(i+1, j), 1, A[i][j] != A[i+1][j]);
				if(j-1 >= 1)
					addEdge(id(i, j), id(i, j-1), 1, A[i][j] != A[i][j-1]);
				if(j+1 <= m)
					addEdge(id(i, j), id(i, j+1), 1, A[i][j] != A[i][j+1]);
			}
		}
	}
	auto ans = mcmf(S, T);
	cout << ans.second << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >    VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SLL(n) scanf("%lld",&n)
#define PLL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
int A[int(1e6)+1];
int main()
{
	int n, t;
	SI(n);
	for(int i = 0 ; i < n ; i++)
		SI(A[i]), A[i] *= -1;
	SI(t);
	for(int i = 0, a ; i < t ; i++)
		SI(a), A[a-1] *= -1;
	reverse(A, A+n);
	stack<int> s;
	for(int i = 0 ; i < n ; i++)
	{
		if(A[i] < 0)
		{
			if(not s.empty() and s.top() == -A[i])
				s.pop();
			else A[i] *= -1, s.push(A[i]);
		}
		else s.push(A[i]);
	}
	if(not s.empty()) return 0*printf("NO\n");
	reverse(A, A+n);
	printf("YES\n");
	for(int i = 0 ; i < n ; i++)
		printf("%d ", -A[i]);
	printf("\n");
	return 0;
}


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

int main(){
	fast;
	int l, d, v, g, r; cin>>l>>d>>v>>g>>r;
    double t2=(double)(l-d)/v;
    double t1=(double)d/v;
    int x=g+r;
    double add=0;
    if((int)t1%(g+r)>=g){
    	float y=(((int)t1/(g+r))+1)*(g+r);
    	//cout<<y<<" "<<t1<<endl;
    	add=y-t1;
    }
    double ans=t1+t2+add;
    cout<<fixed<<setprecision(8)<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

long long n, m, t, k;
vector <long long> a, b;

vector<long long> f(500000), rf(500000);
long long p = 998244353;
void fix(long long &x)
{
	x = ((x % p) + p) % p;
}
long long poww(long long a, long long pp)
{
	if (pp == 0)
		return 1LL;
	if (pp % 2 == 0)
	{
		long long t = poww(a, pp / 2);
		t = t * t;
		fix(t);
		return t;
	}
	else
	{
		long long t = a * poww(a, pp - 1);
		fix(t);
		return t;
	}
}

int main() {
	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);
	cin >> n >> m;
	if (n == 2)
	{
		cout << 0;
		return 0;
	}
	long long c = 1;
	f[0] = 1;
	f[1] = 1;
	rf[1] = 1;
	rf[0] = 1;
	for (long long i = 2; i <= n + m; i++)
	{
		f[i] = f[i - 1] * i;
		fix(f[i]);
		rf[i] = poww(f[i], p - 2);
	}
	long long ans = f[m];
	ans *= rf[m - n + 1];
	fix(ans);
	ans *= rf[n - 1];
	fix(ans);
	ans *= (n - 2);
	fix(ans);
	long long t = poww(2, n - 3);
	ans *= t;
	fix(ans);
	cout << ans;
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <string>
#include <string.h>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
#include <assert.h>

#ifdef WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif // WIN32

#define next(x) (x + ((x) & (-x)))
#define prev(x) (x - ((x) & (-x)))
#define md 1000000007
#define ll long long
#define ull unsigned long long
#define fst first
#define snd second
#define sqr(x) ((x) * (x))
#define INF (1LL << 30)
#define EPS 0.0000000001

using namespace std;

int main() {
	#ifndef DLOCAL
		//freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#else
		//freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif //LOCAL
	int a = 0, b = 0;
	for (int i = 0; i < 3; i++) {
		int x;
		cin >> x;
		b += x;
	}
	for (int i = 0; i < 3; i++) {
		int x;
		cin >> x;
		a += x;
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (a > 0) {
			a -= 10;
		} else if (b > 0) {
					b -= 5;
				}
	}
	if (a > 0 || b > 0) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

	cerr << "Execution time : " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=100000;
const ll P=1000000007;
ll mo[MAX+5],dp[MAX+5],prime[MAX+5],m,ans;
int vis[MAX+5],cnt;
void get_mo(){
	memset(vis,0,sizeof(vis));
	memset(mo,0,sizeof(mo));
	mo[1]=1;
	cnt=0;
	for(int i=2;i<=MAX;i++){
		if(!vis[i]){
			prime[cnt++]=i;
			mo[i]=-1;
		}
		for(int j=0;j<cnt&&prime[j]*i<=MAX;j++){
			vis[prime[j]*i]=1;
			if(i%prime[j]==0) break;
			mo[prime[j]*i]=-mo[i];
		}
	}
}

ll pow(ll a,ll b,ll P){
	if(b==0) return 1;
	ll cnt;
	cnt=pow(a,b/2,P);
	cnt=cnt*cnt%P;
	if(b%2==1) cnt=cnt*a%P;
	return cnt;
}

ll cal(ll x,ll mm){
	ll kk=0;
	for(int i=1;i*i<=x;i++){
		if(x%i==0){
			kk+=mo[i]*(mm/i)%P;
			kk%=P;
			if(x/i!=i){
				kk+=mo[x/i]*(mm/(x/i))%P;
				kk%=P;
			}
		}
	}
	return kk;
}

int main(){
	get_mo();
	scanf("%I64d",&m);
	dp[1]=0;
	for(int i=2;i<=m;i++){
		dp[i]=m;
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				dp[i]+=(cal(i/j,m/j)*dp[j]%P);
				dp[i]%=P;
				if(j!=i/j){
					dp[i]+=(cal(j,m/(i/j))*dp[i/j]%P);
					dp[i]%=P;
				}
			}
		}
		dp[i]=dp[i]*pow(m-m/i,P-2,P)%P;
		dp[i]%=P;
	}
	ans=m;
	for(int i=1;i<=m;i++)
	    ans=(ans+dp[i])%P;
	ans=ans*pow(m,P-2,P)%P;
	ans%=P;
	printf("%I64d\n",ans);
	return 0;
}