// TLE #include #include #include #include using mint = atcoder::modint998244353; mint naive(std::string n_str) { int l = n_str.size(); assert(l <= 20); int n = 0; for (char c : n_str) { n = n * 2 + (c - '0'); } mint ans = 0; for (int i = 0; i < l; ++i) { std::array pd{}; pd[0] = 1; for (int v = 1; v <= n; ++v) { int b = (v >> i) & 1; std::array dp{}; for (int x = 0; x < 2; ++x) { dp[x | b] += pd[x]; dp[x & b] += pd[x]; dp[x ^ b] += pd[x]; } pd = std::move(dp); } ans += (long long) pd[1].val() << i; } return ans; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::string n_str; std::cin >> n_str; std::cout << naive(n_str).val() << std::endl; }