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 Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] a = new int[N-1];
    int[] b = new int[N-1];
    int[] brnch = new int[N];
    int i;
    int K = 0;
    for(i=0;i<N-1;i++){
      a[i] = Integer.parseInt(sc.next());
      b[i] = Integer.parseInt(sc.next());
      brnch[a[i]-1]++;
      brnch[b[i]-1]++;
    }
    for(i=0;i<N;i++){
      if(brnch[i]>K){
        K = brnch[i];
      }
    }
    int[][] color = new int[N][K];
    System.out.println(K);
    int col_i = 0;
    for(i=0;i<N-1;i++){
      col_i = 0;
      while(color[a[i]-1][col_i]!=0 || color[b[i]-1][col_i]!=0)col_i++;
      color[a[i]-1][col_i] = -1;
      color[b[i]-1][col_i] = -1;
      System.out.println(col_i+1);
    }
    System.out.flush();
  }
}