← 返回题目列表

Codeforces · 261/C

C. Maxim 和矩阵

中文机器翻译题面 查看原题

Maxim 喜欢以特殊的方式填充矩阵。 Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1):

Maxim 要求您计算有多少个数字 m (1 ≤ m ≤ n),使得结果矩阵的行号 m + 1 中的单元格中的值之和等于 t。

Expression (x xor y) means applying the operation of bitwise excluding "OR" to numbers x and y. The given operation exists in all modern programming languages. For example, in languages C++ and Java it is represented by character "^", in Pascal — by "xor".

输入

单行包含两个整数 n 和 t (1 ≤ n, t ≤ 1012, t ≤ n + 1)。

请不要使用 %lld 说明符在 C++ 中读取或写入 64 位整数。最好使用 cin、cout 流或 %I64d 说明符。

输出

在一行中打印一个整数——问题的答案。

示例

输入 #1

1 1

输出 #1

1

输入 #2

3 2

输出 #2

1

输入 #3

3 3

输出 #3

0

输入#4

1000000000000 1048576

输出#4

118606527258