#include<cstdio>

int main(void)
{
	int y;

	while(scanf("%d", &y)==1)
	{
		printf("%d\n", 2017-y);
	}

	return 0;
}