Problem:
Score : 100 points

Problem Statement

There are N students in a school.

We will divide these students into some groups, and in each group they will discuss some themes.

You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.

Divide the students so that the number of groups consisting of three or more students is maximized.

Constraints

1 \leq N \leq 1000

All input values are integers.

Input

Input is given from Standard Input in the following format:

N

Output

If you can form at most x groups consisting of three or more students, print x.

Sample Input 1

8

Sample Output 1

2

For example, you can form a group of three students and another of five students.

Sample Input 2

2

Sample Output 2

0

Sometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.

Sample Input 3

9

Sample Output 3

3

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
 
public class Main{
  public static void main(String[] args) {
    try {
      long result;
      int n, i = 0;
      long num[] = {0, 0, 0, 0, 0};
 
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 
      n = Integer.parseInt(reader.readLine());
      String name[] = new String[n];
      char nameF[] = new char[n];
 
      for(i = 0; i < n; i++){
        name[i] = reader.readLine();
      }
      
      for(i = 0; i < n; i++){
        nameF[i] = name[i].charAt(0);
      }
      
      for(i = 0; i < n; i++){
        if (nameF[i] == 'M') {
          num[0] = ++num[0];
        }
        if (nameF[i] == 'A') {
          num[1] = ++num[1];
        }
        if (nameF[i] == 'R') {
          num[2] = ++num[2];
        }
        if (nameF[i] == 'C') {
          num[3] = ++num[3];
        }
        if (nameF[i] == 'H') {
          num[4] = ++num[4];
        }
      }
 
      result = num[0]*num[1]*(num[2]+num[3]+num[4])+num[0]*num[2]*(num[3]+num[4])+num[0]*num[3]*num[4]
               +num[1]*num[2]*(num[3]+num[4])+num[1]*num[3]*num[4] + num[2]*num[3]*num[4];
      
      System.out.println(result);
    }
    catch (Exception e) {
      
    }
  }
}