#include #include #include #include #include #include #include #include #define MOD 1000000007 #define ll long long #define ld long double #define rep(i,n) for(ll i =0;i> A >> B >> P; A[A.size()-1]-=1; ll na = withModDP(A,3,3,stoi(P)); ll nb = withModDP(B,3,3,stoi(P)); cout << nb - na << endl; }