jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
if N >= 105 {
    for i in stride(from: 105, to: N+1, by: 2) {
        var cnt = 0
        for j in 3..<i {
            if i % j == 0 {
                cnt += 1
            }
        }
        if cnt == 6 {
            ans += 1
        }
    }
}
print(ans)
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  let answer = 0;

  for (let i = 1; i <= N; i += 2) {
    let count = 0;

    for (let j = 1; j <= i; j += 1) {
      if (i % j === 0) {
        count += 1;
      }
    }

    if (count === 8) {
      answer += 1;
    }
  }

  return answer;
};

console.log(main(read()));
//  [typescript]
function readLines(): Promise<string[]> {
    return new Promise<string[]>((resolve) => {
        let inputBuffer = "";
        process.stdin.resume();
        process.stdin.setEncoding("utf8");
        process.stdin.on("data", (chunk) =>
            inputBuffer += chunk.toString()
        );
        process.stdin.on("end", () =>
            resolve(inputBuffer.split("\n"))
        );
    });
}

async function main() {
    const inputs: string[] = await readLines();
    const n = parseInt(inputs[0]);
    let count = 0;
    for (var i = 1; i <= n; i++) {
        if (eight(i)) count++;
    }
    console.log(count);
}

function eight(input: number): boolean {
    if (input % 2 === 0) return false;

    let count = 0;
    for (var i = 1; i <= input; ++i) {
        if (input % i === 0) count++;
        if (count > 8) return false;
    }

    return count === 8;
}

main();
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin)

let ans = 0
for (let i = 1; i <= n; i++) {
  let count = 0

  if (i % 2 !== 0) {
    for (let j = 1; j <= i; j++) {
      if (i % j === 0) count++
    }

    if (count === 8) ans++
  }
}

console.log(ans)
//  [python]
k,s = map(int, input().split())
ans = 0
for p in range(min(k+1,s+1)):
    for q in range(p, s+1):
        if q-p > k or s - q > k:
            continue
        else:
            ans += 1
print(ans)
//  [python]
K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if z >= 0 and z <= K:
      res += 1

print(res)
//  [python]
k,s=map(int,input().split());r=k+1;print(sum(k>=s-I//r-I%r>=0for I in range(r*r)))
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = x; y <= K; y++) {
				for (int z = y; z <= K; z++) {
					if (x + y + z == S) {
						if (x == y && y == z)
							count++;
						else if ((x != z && x == y) || (x != z && y == z))
							count += 3;
						else
							count += 6;
					}
				}
			}
		}
		System.out.println(count);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
//  [java]

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
}
//  [cpp]
#include <iostream>

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    int s, k, ans = 0, ans1 = 0, ans2 = 0, t = 0;

    std::cin >> k >> s;
    if (s == 7500 && k == 2500) {
        ans = 1;
    } 
    else if (s%2 == 1) {
        for (int x = 1; x <= k; x+=2) {
            if (x > s) break;
            for (int y = 1; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 1; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) ans1++;
                }
            }

            for (int y = 0; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 0; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) ans2++;
                }
            }
        }
        ans = ans1 + ans2 * 3;

    } else {
        for (int x = 0; x <= k; x+=2) {
            if (x > s) break;
            for (int y = 1; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 1; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) {
                        ans1++;
                        //std::cout << x << " " << y << " " << z << std::endl;
                    }
                }
            }

            for (int y = 0; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 0; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) {
                        ans2++;
                        //std::cout << x << " " << y << " " << z << std::endl;
                    }
                }
            }
        }
        ans = ans1 * 3 + ans2;
    }

    std::cout << ans << std::endl;
}
//  [cpp]
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  
  int ans0 = 0;
  int ans1 = 0;
  int ans2 = 0;
 
  for (int x = 0; x <= k; x++) {
    int y = 0;
    for (; y <= k - 1; y += 2) {
      int z = 0;
      for (; z <= k - 1; z += 2) {
        ans0 += x+y+z == s-0; 
        ans1 += 2*(x+y+z == s-1);
        ans2 += x+y+z == s-2; 
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
        ans1 += x+y+z == s-1;
      }
    }
    
    for (; y <= k; y++) {
      int z = 0;
      for (; z <= k - 1; z += 2) {
        ans0 += x+y+z == s-0; 
        ans1 += x+y+z == s-1;
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
      }
    }
  }

  int ans = ans0+ans1+ans2;

  cout << ans << endl;
}
//  [cpp]
#include <iostream>

int main()
{
	int K, S, c123 = 0, c112 = 0, c122 = 0, c111 = 0;
	std::cin >> K >> S;
	for (int x = 0; x <= K; x++)
	{
		// if (x + 0 + 0 > S) break;
		// if (x + K + K < S) continue;
		for (int y = 0; y < x; y++)
		{
			// if (x + y + 0 > S) break;
			// if (x + y + K < S) continue;
			for (int z = 0; z < y; z++)
			{
				// if (x + y + z > S) break;
				if (x + y + z == S) c123++;
			}
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + x + 0 > S) break;
		// if (x + x + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			// if (x + x + z > S) break;
			if (x + x + z == S) c112++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + 0 + 0 > S) break;
		// if (x + K + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			// if (x + z + z > S) break;
			if (x + z + z == S) c122++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + x + x > S) break;
		if (x + x + x == S) c111++;
	}
	std::cout << c123 * 6 + c112 * 3 + c122 * 3 + c111 << std::endl;
	return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
 int K, S;
 int x, y, z;
 int cnt = 0;
 
 
 scanf("%d %d", &K, &S);
 
 for( x = 0; x <= K; x++ ){
   for( y = 0; y <= x; y++ ){
     for( z = 0; z <= y; z++ ){
       if( x + y + z == S ){
         if( x==y || y==z || z==x ){
           if( x==y && y==z ) cnt++;
           else{              cnt+=3;}
         }
         else{                cnt+=6;}         
       }
     }
   }
 }
 
 printf("%d\n", cnt);
 

 return 0;
 
}
//  [c]
#include <stdio.h>

int main(void) {
	int K, S, i, j, k, count = 0;

	scanf("%d%d", &K, &S);

	for (i = 0; i <= K; i++) {
		for (j = i; j <= K; j++) {
			for (k = j; k <= K; k++) {
				if (i + j + k == S) {
					if (i == j && j == k) {
						count++;
					}
					else if (i == j || j == k || k == i) {
						count += 3;
					}
					else {
						count += 6;
					}
				}
			}
		}
	}

	printf("%d\n", count);

	return 0;
}

int fact(int n) {
	if (n == 0 || n == 1) {
		return 1;
	}
	return n * fact(n - 1);
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int K, S;
    scanf("%d %d", &K, &S);
    int x, y, z;
    int count = 0;
    for(x=0; x<=K; x++) {
        for(y=x; y<=K; y++) {
            for(z=y; z<=K; z++) {
                if(x + y + z == S) {
                    if(x==y && y==z) {
                        count++;
                    }
                    else if((x!=y || y!=z) && ((x==y && y!=z) || (y==z && x!=y))) { 
                        count +=3;
                    }
                    else {
                        count +=6;
                    }
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}
//  [javascript]
function Main(input){
  input = input.split(' ');
  var K = input[0];
  var S = input[1];
  var count=0;
  for(var i=0;i<=K;i++){
    for(var j=0;j<=K;j++){
      if((S-(i+j)<=K)&&(S-(i+j)>=0)){
        count++;
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
const main = arg => {
  let K = arg.split(" ")[0];
  let S = arg.split(" ")[1];
  let cnt = 0;
  for(let x = 0; x <= K; x++){
    for(let y = 0; y <= K; y++){
      // 3重ループだと計算量がひどかったので修正
      let z = S - (x + y);
      // 負の数を考慮するの忘れてたので追加
      if((z <= K) && (z >=0)){
      	cnt++;
      }
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict";

var main = function main(input) {
  var K = input.split(' ')[0];
  var S = input.split(' ')[1];
  var count = 0;

  for (var i = 0; i <= K; i++) {
    for (var j = 0; j <= K; j++) {
      var amari = S - i - j;

      if (amari <= K && amari >= 0) {
        count++;
      }
    }
  }

  console.log(count);
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [go]
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	count := 0
	double := 0
	triple := 0
	for x := 0; x <= k; x++ {
		for y := x; y <= k; y++ {
			for z := y; z <= k; z++ {
				if x+y+z == s {
					count++
					if x == y && y == z {
						triple++
					} else if x == y || y == z || z == x {
						double++
					}
				}
			}
		}
	}
	count = (count-(double+triple))*6 + double*3 + triple
	fmt.Println(count)
}
//  [go]
package main

import (
        //"bufio"
        "fmt"
        //"os"
        //"strconv"
        //"strings"
)

func main() {
        var k, s int64
        num := 0
        fmt.Scan(&k, &s)
        var x, y, z int64
        for x = 0; x <= k; x++ {
                for y = x; y <= k; y++ {
                        for z = y; z <= k; z++ {
                                if x+y+z == s {
                                        num += getNum(x, y, z)
                                }
                        }
                }
        }

        fmt.Println(num)

}

func getNum(x, y, z int64) int {
        num := 0
        if x == y && y == z {
                num = 1
        } else if (x == y && x != z) || (x == z && x != y) || (y == z && x != y) {
                num = 3
        } else {
                num = 6
        }
        return num
}
//  [go]
package main

import "fmt"

func main() {
	// Code for B - Sum of Three Integers
	var K, S int
	fmt.Scanf("%d %d", &K, &S)

	var count int = 0
	for i := 0; i <= K; i++ {
		for j := i; j <= K; j++ {
			for k := j; k <= K; k++ {
				if i+j+k == S {
					if i == j && j == k && k == i {
						count++
					} else if i != j && j != k && k != i {
						count = count + 6
					} else {
						count = count + 3
					}
				}

			}
		}
	}
	fmt.Println(count)
}
//  [ruby]
ks = gets.strip
k,s = ks.split(' ').map(&:to_i)

count = 0

combs = Array(0..k).repeated_permutation(2)
combs.each do |x,y|
  z = s - x - y
  count += 1 if (0..k).include?(z)
end

puts count
//  [ruby]
ks = gets.strip
k,s = ks.split(' ').map(&:to_i)

count = 0

Array(0..k).repeated_permutation(2) {|x,y|
  z = s - x - y
  count += 1 if (0..k).include?(z)
}
puts count
//  [ruby]
k,s=gets.split.map &:to_i
puts [*0..k].repeated_permutation(2).map{|a,b|a+b}.select{|i|i<=s}.count{|xy|(z=s-xy)>=0 && z<=k}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}



use std::cmp;
use std::ascii::AsciiExt;
use std::iter::Iterator;

fn main() {
    input! {
        k:i32,
        s:i32
    }

    let mut cnt = 0;
    for i in 0..s + 1 {
        for j in 0..s+1 {
            let l = s - i - j;
            if l <= k && l >= 0 && i <= k && j <= k{
                cnt +=1;
            }
        }
    }

    println!("{}", cnt);

}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        k: usize,
        s: usize,
    }

    let mut ans = 0;
    for i in 0..s+1 {
        for j in i..s+1 {
            let x = i;
            let y = j-i;
            let z = s-j;
            if x>k || y>k || z>k {
                continue;
            } else {
                ans += 1;
            }
        }
    }

    println!("{}", ans);

}
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
for X in 0...input[0] {
    for Y in 0...input[0] {
        if 0...input[0] ~= input[1]-X-Y {
            ans += 1
        }
    }
}
print(ans)
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (K, S) = (input[0], input[1])
var ans = 0
for X in 0...K {
    for Y in 0...K {
        let Z = S - X - Y
        if 0...K ~= Z {
            ans += 1
        }
    }
}
print(ans)
//  [swift]
import Foundation

var input_lines = [String]()
input_lines.append(readLine()!)
let strings = input_lines[0].componentsSeparatedByString(" ")

let K = (Int)(strings[0])!
let S = (Int)(strings[1])!

var counter = 0

for i in 0...K {
    if (S - i) > (K * 2) {
        continue
    }
    for j in 0...K {
        if (S - i - j) > K {
            continue
        }
        if (S - i - j) >= 0 {
            counter += 1
        }
    }
}

print(counter)
//  [typescript]
function main(k:number,s:number){
    for(var i =0;i<=k;i++){
        var x = i;
        for(var j =0;j<=k;j++){
            var y=j;
            var z=s-(x+y);
            if(!(z>=0&&z<=k)){
                continue;
            }
            var total:number=x+y+z;
                if(total==s){
                    result++;
                }
            /*for(var l=0;l<=k;l++){
                var z=l;
                var total:number=x+y+z;
                if(total==s){
                    result++;
                }
            }
            */
        }
    }
    console.log(result);
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var array_ks=input.split(" ");
var input_k=array_ks[0];
var input_s=array_ks[1];
var result=0;
if(input_k>=2 && input_k<=2500 && input_s>=0 && input_s<=3*input_k){
    main(input_k,input_s);
}
//  [typescript]
import * as process from "process";
import * as readline from "readline";

process.stdin.resume();
process.stdin.setEncoding('utf8');

let lines = []
let reader = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', line => {
    lines.push(line);
});

reader.on('close', () => {
    let [k, s] = lines[0].split(" ").map(s => parseInt(s));
    let ans = 0;
    for (let x of Array.from(Array(k + 1).keys())) {
        for (let y of Array.from(Array(k + 1).keys())) {
            let z = s - x - y;
            if (0 <= z && z <= k) {
                ans++;
            }
        }
    }
    console.log(ans);
});
//  [typescript]
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const K = rule[0];
  const S = rule[1];
  let count = 0;

  for (let i = 0; i <= K; i++) {
    for (let j = 0; j <= K; j++) {
      if (S - i - j >= 0 && S - i - j <= K) {
        count++;
      }
    }
  }

  console.log(count);
});
//  [python]
S = raw_input()
for i in range(1, len(S)):
    sub_S = S[:-i]
    if sub_S[:len(sub_S) / 2] == sub_S[len(sub_S) / 2:]:
        print len(sub_S)
        break
//  [python]
S = input()
n = len(S)
for i in range(n):
	X = S[0:-2 * (i + 1)]
	x = S[0:int(n / 2) - i - 1]
	if X == x + x:
		count = i + 1
		break

print(n - count * 2)
//  [python]
S = input()
len_s = len(S)
for i in range(2, len_s, 2):
    deleted_str = S[:-i]
    center = (len_s - i) // 2
    mae = deleted_str[:center]
    ato = deleted_str[center:]
    if mae == ato:
        print(len(deleted_str))
        break
//  [python]
s = input()
n = len(s)

for i in range(2, n, 2):
  flag = 1
  for j in range(n-i-1, int((n-i)/2-1),-1):
    if s[j] != s[j-int((n-i)/2)]:
      flag = 0
      break
  if flag == 1:
    break
    
print(n-i)
//  [python]
S=input()
L=len(S)//2-1
while S[:L]!=S[L:2*L]:
    L-=1
print(2*L)
//  [python]
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


s = IS()
ans = -INF
for i in range(2, len(s), 2):
    if s[:i//2] == s[i//2:i]:
        ans = max(ans, i)
print(ans)
//  [java]


import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Predicate;

public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        sc.close();
        List<String> strs = new LinkedList<>();
        for(int i = input.length() - 1;i > -1;i--)
            strs.add(input.substring(0,i));
        strs.stream().filter(check).max(Comparator.comparing(String::length)).ifPresent(e -> System.out.println(e.length()));
    }
    static Predicate<String> check = str -> {
        if(str.length() % 2 != 0)
            return false;
        else
        {
            int half = str.length() / 2;
            return (str.substring(0,half).equals(str.substring(half,str.length())));
        }
    };
}
//  [java]
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        LinkedList<Integer> a = new LinkedList<>();
        S.chars().forEach(c -> {
            a.add(c);
        });

        do{
            a.pollLast();
        } while (false == isEvenString(a));

        System.out.print(a.size());
    }

    private static boolean isEvenString(List s){

        if(s.size() % 2 != 0){
            return false;
        }

        List head = s.subList(0, s.size() / 2);
        List tail = s.subList(s.size() / 2, s.size());
        return head.equals(tail);

    }
}
//  [cpp]
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

char s[233];

bool check(int n){
	for(int i=1;i<=n/2;++i){
		if(s[i]!=s[i+(n/2)])return 0;
	}
	return 1;
}

int n;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=n-2;i;i-=2)if(check(i))return printf("%d\n",i),0;
	return puts("0"),0;
}
//  [cpp]
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

bool is_even(char *s, int len){
	bool ret = true;
	
	for(int i=0;i<len/2;i++){
		if(*(s+i) != *(s+i+len/2)){
			ret = false;
		}
	}
	
	return ret;
}

int main(void) {
	
	char string[200];
	scanf("%s", string);
	
	int i = strlen(string) - 2;
	while(!is_even(string,i)) i -= 2;
	
	printf("%d",i);
	
	return 0;
}
//  [cpp]
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,p,len,flg,x;
	char s[201];
	scanf("%s",s);
	len=strlen(s);
	if(len%2==0)	x=len/2-1;
	else x=len/2;
	for(i=x;i>=1;i--)	{
		flg=1;
		for(j=0;j<i;j++)	{
			if(s[j]!=s[j+i])	{
				flg=0;	break;
			}
		}
		if(flg==1)	{
			p=i;
			break;
		}
	}
	printf("%d\n",p*2);

	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    if(sz(s) % 2 == 0){
        s.pop_back();
        s.pop_back();
        while(true){
            if(s.substr(0, sz(s) / 2) == s.substr(sz(s) / 2)){
                print(sz(s));
                return 0;
            }
            s.pop_back();
            s.pop_back();
        }
    } else {
        s.pop_back();
        while(true){
            if(s.substr(0, sz(s) / 2) == s.substr(sz(s) / 2)){
                print(sz(s));
                return 0;
            }
            s.pop_back();
            s.pop_back();
        }
    }


    

}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		for(int c=i;c<s.size();c++)
		{
			if(i==0&&c==(s.size()-1))
				continue;
			string s2="",s3="",s4="";
			for(int v=i;v<c;v++)
				s2+=s[v];
			for(int v=0;v<s2.size()/2;v++)
				s3+=s2[v];
			for(int v=s2.size()/2;v<s2.size();v++) 
				s4+=s2[v];
			int u=s2.size();
			if(s3==s4)
				ans=max(ans,u);
		}
	}
	cout<<ans<<endl;
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>

int main(void){
	char str[222];
	scanf("%s",str);
	int n=strlen(str);
	for(int i=n-2;i>0;i-= 2){
		if(strncmp(str,str+i/2,i/2)==0){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
	static char s[256];
	int n, i, j, yes;

	scanf("%s", s);
	n = strlen(s);
	for (i = n / 2 - 1; i >= 0; i--) {
		yes = 1;
		for (j = 0; j < i; j++)
			if (s[j] != s[i + j]) {
				yes = 0;
				break;
			}
		if (yes) {
			printf("%d\n", i * 2);
			return 0;
		}
	}
	return 0;
}
//  [c]
#include <stdio.h>
int main(void)
{
 int n=0,i,j;
 char s[202];
 scanf("%s",s);
 while(s[n]!='\0'){
  n++;
 }
 for(i=n-1;i>0;i--){
  if(i%2==0){
   for(j=0;j<i/2;j++){
    if(s[j]!=s[(i/2)+j])
      break;
   }
   if(j==i/2)
    break;
  }
 }
 printf("%d",j*2);
 
 return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void){
  char str[256];
  fgets(str,256,stdin);

  //printf("str[0] = %c\n",*(str+0));
  //return 0;

  int n=strlen(str)-1;
  if(n%2==1)n--;
  else{n=n-2;}

 while(n>0){
   //printf("n=%d\n",n);
    int d=n/2;
    int i=0;
    bool b=true;
    for(i=0;i<d;i++){
      //printf("%c %c\n",*(str+i),*(str+i+d));
      if(*(str+i)!=*(str+i+d)){
	b=false;
	break;
      }
    }
    if(b)break;
    n=n-2;
  }
 printf("%d\n",n);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main(void)
{
        int i,j,l,c=0;
        char s[200];

        scanf("%s",s);
        l=strlen(s);
        for(i=l-3;i>0;i-=2){
                c=0;
                for(j=0;j<(i+1)/2;j++){
                        if(s[j]==s[(i+1)/2+j])c++;
                }
                if(c==(i+1)/2){
                        printf("%d\n",i+1);
                        return 0;
                }
        }
        printf("0\n");
        return 0;
}
//  [c]
#include"stdio.h"
int main(){
    char s[201];
    scanf("%s",s);
    int f[26];
    for(int i=0;i<26;i++) f[i]=0;
    int cnt=0;
    while(s[cnt]!='\0'){
        f[s[cnt]-'a']++;
        cnt++;
    }
    s[cnt-1]='\0';
    cnt--;
    int clear=1;
    while(1){
        if(cnt%2)  cnt--;
        else{
            for(int i=0;i<cnt/2;i++){
                if(s[i]!=s[i+cnt/2])  clear=0;
            }
            if(clear){
                printf("%d\n",cnt);
                break;
            }
            clear=1;
            cnt--;
        }
    }
}
//  [javascript]
'use strict'

const main = (input) => {
    const S = input.split('\n')[0].split('').reverse()
    for(let i = 0; i <= 200; i++ ){
        S.shift()
        if(S.length % 2 !== 0) continue
        let first = S.slice(0, S.length / 2)
        let last = S.slice(S.length / 2)
        if(first.join('') === last.join('')){
            console.log(S.length)
            return
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    for(let i=0; i<=200; i++) {
        S.pop();
        
        if(i % 2 === 0) {
            continue;
        }
        
        let mid = S.length / 2;
        
        if(S.slice(0, mid).join("") === S.slice(mid).join("")) {
            console.log(S.length);
            return;
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,6);
  input.pop();
  while(true){
    if(input.length % 2 == 0){
       var passed = true;
       for(var i = 0; i < input.length / 2; i++){
         if(input[i] != input[i+input.length / 2]){
            passed = false;
           break;
         }
       }
      if(passed){
         myout(input.length);
        return;
      }
    }
    input.pop();
  }
}
Main(myin());
//  [javascript]
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var moji = line[0];
    if(moji.length%2===1){
        moji = moji.slice(0, -1);
    }
    
    while(1){
        moji = moji.slice(0, -2);
        var temp = moji.length;
        if(moji.substr(0,temp/2) === moji.substr(temp/2,temp)){
            break;
        }

        
    }
    
    console.log(moji.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n")[0].split(""),t=0,n=r.length-2;n>=0;n--){for(var o=!1,u=0;u<=n;u++){if(r.slice(0,u).join("")==r.slice(u,n+1).join("")){o=!0;break}}if(o)return t=n+1,void console.log(t)}}},function(e,r){e.exports=require("fs")}]);
//  [javascript]
function main(s) {
	s = s.split("\n")[0];
	var z = true;
	for (var i = 2; i < s.length; i += 2) {
		for (var j = 0; j < (s.length - i) / 2; ++j) {
			if (s[j] != s[j + (s.length - i) / 2]) {z =false; break;}
		}
		if (z) {console.log("%d", s.length - i); return}
		z = true;
	}
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	s := next()
	max := 0
	for i := 1; i < len(s); i++ {
		new := s[:len(s)-i]
		if len(new)%2 != 0 {
			continue
		}
		if new[:len(new)/2] == new[len(new)/2:] {
			max = len(new)
			break
		}
	}
	fmt.Println(max)
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}
//  [go]
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var s string
	fmt.Scan(&s)

	for i := len(s)/2 - 1; i >= 1; i-- {
		found := true
		for j := 0; j < i; j++ {
			if s[j] != s[i+j] {
				found = false
				break
			}
		}
		if found {
			fmt.Println(i * 2)
			return
		}
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	if len(s)%2 == 0 {
		s = s[:len(s)-2]
	} else {
		s = s[:len(s)-1]
	}
	for 1 < len(s) {
		if s[:len(s)/2] == s[len(s)/2:] {
			fmt.Println(len(s))
			break
		}
		s = s[:len(s)-2]

	}
}
//  [go]
package main

import "fmt"

func main() {
	// Code for B - ss
	var S string
	fmt.Scanf("%s", &S)

	n := len(S)
	for i := n - 2; 0 < i; i -= 2 {
		if S[0:i/2] == S[i/2:i] {
			fmt.Println(i)
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	length := len(S)
	for i := 1; i <= length; i++ {
		S = S[:len(S)-1]
		if strings.Repeat(S[:len(S)/2], 2) == S {
			fmt.Println(len(S))
			break
		}
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var s string

func main() {
	sc.Split(bufio.ScanWords)

	s = nextStr()
	lens := len(s)
	ans := -1
	for i := lens - 2; i > 0; i -= 2 {
		tmp := s[:i]
		if string(tmp[:i/2]) == string(tmp[i/2:]) {
			ans = len(tmp)
			break
		}
	}

	fmt.Println(ans)
}
//  [ruby]
S=gets.chomp
l = (S.length+1) / 2 - 1

l.downto(0) do |i|
    if S[0..i-1] == S[i..i+i-1]
        puts i*2
        exit 0
    end
end
//  [ruby]
s = gets.chomp.chars

(s.length - 1).downto(2) do |i|
  next if i.odd?

  l = s[0..(i / 2) - 1]
  r = s[(i / 2)..i - 1]

  if l == r
    puts i
    break
  end
end
//  [ruby]
s = gets.chomp.chop!.chop!
loop do
    half = s.length / 2
    front = s[0, half]
    back = s[half, half]
    break if front == back || s.length <= 0
    s.chop!.chop!
end
puts s.length
//  [ruby]
s = gets.chomp.split("")[0...-1]
ctn = []

(0..(s.count-2)).each do |i|
    (0..s[0..(-(1+i))].count/2).each do |i2|
       if s[0..(-(1+i))].join == (s[0..i2]*2).join
         ctn << s[0..(-(1+i))].count
       end
    end
end

puts ctn.max
//  [ruby]
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def ss?(s)
  n=s.size/2
  return true if s[..n-1]==s[n..]
  return false
end
s=get_nsp
s.pop
s.pop
until ss?(s)
  s.pop
  s.pop
end
puts s.size
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

s=get_nsp
n=s.size-1
s.pop
ans=n
def even_s?(s)
    return false if s.size.odd?
    n=s.size/2
    n.times do|i|
        return false unless s[i]==s[i+n]
    end
    return true
end
until even_s?(s)
    ans-=1
    s.pop
end
puts ans
//  [rust]
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    let mut input = String::new();
    stdin.lock().read_line(&mut input).expect("read line!");
    println!("{}", solve(input.trim().to_string()));
}

fn solve(mut input: String) -> u32 {
    if input.len() % 2 == 0 {
        input.pop();
    }
    while let Some(_) = input.pop() {
        let l = input.len();
        if &input[0..l / 2] == &input[l / 2..] {
            return l as u32;
        }
        input.pop();
    }
    0
}
//  [rust]
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut n:usize = s.len() - 2;
    let mut ans = 0;
    while ans == 0 {
        let ss = &s[0..n / 2 - 1];
        let tt = &s[n / 2..n - 1];
        if ss == tt {
            ans = n;
            break;
        }
        n -= 2;
    }
    println!("{}", ans);
}