#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #define rep(i, n) for (ll i = 0; i < (n); i++) #define srep(i, s, n) for (ll i = s; i < (n); i++) #define len(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() using namespace std; template using vc = vector; template using vv = vc>; template using vvv = vv>; using vi = vc; using vvi = vv; using vvvi = vv; using ll = long long; using vl = vc; using vvl = vv; using vvvl = vv; using ld = long double; using vld = vc; using vvld = vc; using vvvld = vc; using uint = unsigned int; using ull = unsigned long long; const ld pi = acos(-1.0); const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; // const ll mod = 1000000007; inline bool inside(ll y, ll x, ll H, ll W) { return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); } #define debug(var) \ do { \ cerr << #var << " :\n"; \ view(var); \ } while (0) template void view(const T &e) { cerr << e; } template void view(const pair &p) { cerr << "{" << p.first << ", " << p.second << "}"; } template void view(const vc &v) { for (const auto &e : v) { view(e); cerr << " "; } cerr << endl; } template void view(const vv &vv) { for (const auto &v : vv) { view(v); } cerr << endl; } template void view(const set &s) { for (const auto &e : s) { view(e); cerr << " "; } cerr << endl; } template void view(const multiset &s) { for (const auto &e : s) { view(e); cerr << " "; } cerr << endl; } template void view(const unordered_set &s) { for (const auto &e : s) { view(e); cerr << " "; } cerr << endl; } template void view(const map &mp) { for (const auto &e : mp) { view(e); cerr << " "; } cerr << endl; } // constexpr long long mod = 1000000007; constexpr long long mod = 998244353; class mint { private: long long x; public: constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {} constexpr mint &operator+=(const mint &a) { x += a.x; if (x >= mod) x -= mod; return *this; } constexpr mint &operator-=(const mint &a) { x += mod - a.x; if (x >= mod) x -= mod; return *this; } constexpr mint &operator*=(const mint &a) { x *= a.x; x %= mod; return *this; } constexpr mint operator+(const mint &a) const { mint res(*this); return res += a; } constexpr mint operator-(const mint &a) const { mint res(*this); return res -= a; } constexpr mint operator*(const mint &a) const { mint res(*this); return res *= a; } constexpr mint pow(long long r) const { if (r == 0) return 1; mint a = pow(r >> 1); a *= a; if (r & 1) a *= *this; return a; } constexpr mint comb(long long n, long long r) const { mint a = 1; for (int i = 1; i <= r; i++) { a *= n - i + 1; a /= i; } return a; } // 素数のときのみ使用可能 constexpr mint inv() const { return pow(mod - 2); } constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); } constexpr mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; class BiominalCoefficient { private: vector fact; vector finv; vector inv; public: BiominalCoefficient(int n) : fact(n), finv(n), inv(n) { fact[0] = fact[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < n; i++) { fact[i] = fact[i - 1] * i; inv[i] = (mint)mod - inv[mod % i] * mint(mod / i); finv[i] = finv[i - 1] * inv[i]; } } mint get(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fact[n] * finv[k] * finv[n - k]; } }; int main() { int N; cin >> N; mint ans = 0; for (int i = 0; i <= N; i++) { for (int j = i; j <= N; j++) { if (__builtin_popcount(i) == __builtin_popcount(j)) { ans += mint(i & j); } } } cout << ans << endl; return 0; }