#include #include #include #include #include #include #include #include #include #include using namespace std; #define MOD 1000003 // n / d struct Rational{ int n; int d; Rational(int n_, int d_) : n(n_), d(d_){ } Rational operator+(const Rational &x) const{ return Rational(this->n + x.n, this->d + x.d); } }; int main(){ long long L; cin >> L; function Stern_Brocot_Tree = [&](const Rational &low, const Rational &high) -> int{ Rational med = low+high; int n = med.n; int m = med.d; if( 8LL*m*(n+m) > L ) return 0; int ret = ((m-n)%2==0)?0:1; ret += Stern_Brocot_Tree(low, med); ret += Stern_Brocot_Tree(med, high); return ret; }; int ans = Stern_Brocot_Tree(Rational(0,1), Rational(1,1)); ans %= MOD; cout << ans << endl; return 0; }