Problem:
Score : 100 points

Problem Statement

Given is a string S representing the day of the week today.

S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.

After how many days is the next Sunday (tomorrow or later)?

Constraints

S is SUN, MON, TUE, WED, THU, FRI, or SAT.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of days before the next Sunday.

Sample Input 1

SAT

Sample Output 1

1

It is Saturday today, and tomorrow will be Sunday.

Sample Input 2

SUN

Sample Output 2

7

It is Sunday today, and seven days later, it will be Sunday again.

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

//#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 1
#define N_MAX 100000

#define X_MIN 0
#define X_MAX 100000

#define T_MIN 1
#define T_MAX 100000
int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	int N;
	int T[N_MAX];
	int X[N_MAX];
	int Y[N_MAX];
	fscanf(stdin,"%d",&N);
	ASSERT_RANGE(N_MIN,N,N_MAX);
	{
		int i;
		for (i = 0; i < N; i++) {
			fscanf(stdin,"%d%d%d",&T[i],&X[i],&Y[i]);
			ASSERT_RANGE(T_MIN,T[i],T_MAX);
			ASSERT_RANGE(X_MIN,X[i],X_MAX);
			ASSERT_RANGE(X_MIN,Y[i],X_MAX);
		}
	}

	int pre_t = 0;
	int pre_x = 0;
	int pre_y = 0;

	{
		int i;
		for (i = 0; i < N; i++) {
			int cur_t = T[i];
			int cur_x = X[i];
			int cur_y = Y[i];

			int diff_t = cur_t - pre_t;
			assert(diff_t > 0);
			int diff_x = abs(cur_x - pre_x);
			int diff_y = abs(cur_y - pre_y);
			int distance = diff_x + diff_y;

			if (distance > diff_t) {
				fprintf(stdout,"No\n");
				return 0;
			}
			if (distance == diff_t) {
				pre_t = cur_t;
				pre_x = cur_x;
				pre_y = cur_y;
				continue;
			}
			int waiting = diff_t - distance;
			if (waiting % 2 != 0) {
				fprintf(stdout,"No\n");
				return 0;
			}
			pre_t = cur_t;
			pre_x = cur_x;
			pre_y = cur_y;
		}
	}
	fprintf(stdout,"Yes\n");
	return 0;
}