import sys input = sys.stdin.readline S,K=map(int,input().split()) print(S%1000)