#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
#define PB push_back
#define MK make_pair
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

const int maxn = 5000 + 5;
const int modu = 998244353; // 1e9 + 7
const int inf = 0x3f3f3f3f;
const double eps = 1e-5;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

typedef long long LL;

void read(LL &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

void read(int &x) { LL y; read(y); x = (int)y; }
void read(char &ch) { char s[3]; scanf("%s", s); ch = s[0]; }
void read(char *s) { scanf("%s", s); }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }

int n, m;
int a[maxn];
LL inv[maxn], c[maxn], f[20][maxn];
int b[20];

int main() {
    // freopen("my.txt", "w", stdout);
    read(n, m);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = (modu - (modu/i))*inv[modu%i]%modu;
    c[0] = 1;
    for (int i = 1; i <= n; ++i)
        c[i] = (n-i+1)*inv[i]%modu*c[i-1]%modu;
    int nb = 0;
    while (m) {
        b[nb++] = m%2;
        m /= 2;
    }
    memset(f, 0, sizeof(f));
    f[nb-1][0] = 1;
    int tot = b[nb-1];
    for (int i = nb-2; i >= 0; --i) {
        for (int j = 0; j <= tot*2 + b[i]; ++j) if (j%2 == 0) {
            for (int k = 0; k <= j && k <= n; k += 2)
                f[i][j] = (f[i][j] + f[i+1][(j-k)/2]*c[k]) % modu;
        }
        tot = tot*2 + b[i];
    }
    printf("%lld\n", f[0][tot]);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll c = 1;
  while (c * 1000 <= n) {
    c *= 1000;
    ans += n - c + 1;
  }
  cout << ans << endl;
}