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 Rust (1.15.1) (judge verdict: Accepted)

#![allow(unused_imports, unused_variables, dead_code)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

// https://beta.atcoder.jp/contests/arc065/tasks/arc065_b

// 各ノードが接続しているノードを2次元配列で返す
fn node_to_list(node_num: usize, link_num: usize, sc: &mut Scanner) -> Vec<Vec<usize>> {
    let mut ret: Vec<Vec<usize>> = vec![Vec::new(); node_num];
    for i in 0..link_num {
        let (p, q): (usize, usize) = (sc.read(), sc.read());
        ret[p-1].push(q-1); ret[q-1].push(p-1);
    }
    ret
}

fn dfs(
    paths: &Vec<Vec<usize>>,
    cnct: &mut Vec<i32>,
    p: usize,
    num: i32
) {
    cnct[p] = num;
    for next in paths[p].iter() {
        if cnct[*next] == -1 {
            dfs(paths, cnct, *next, num);
        }
    }
}

fn main() {
    let cin = stdin(); let cin = cin.lock(); let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    if n > 2 { println!("{}", n / 3); }
    else { println!("0"); }
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}