jiahuimbzuai/CoQuIR huggingface dataset:
//  [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!{
        c: [[usize; 3]; 3],
    }

    let mut tmp1 = 0;
    let mut tmp2 = 0;
    let mut tmp3 = 0;
    for i in 0..3 {
        for j in 0..3 {
            if i==0 {
                tmp1 += c[i][j];
            } else if i==1 {
                tmp2 += c[i][j];
            } else {
                tmp3 += c[i][j];
            }
        }
    }

    if (((tmp1 as i64) - (tmp2 as i64)).abs() % 3 == 0
    && ((tmp2 as i64) - (tmp3 as i64)).abs() % 3 == 0
    && ((tmp1 as i64) - (tmp3 as i64)).abs() % 3 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
    
}
//  [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!{
        c: [[usize; 3]; 3],
    }

    let mut tmp1 = 0;
    let mut tmp2 = 0;
    let mut tmp3 = 0;
    for i in 0..3 {
        for j in 0..3 {
            if i==0 {
                tmp1 += c[i][j];
            } else if i==1 {
                tmp2 += c[i][j];
            } else {
                tmp3 += c[i][j];
            }
        }
    }

    if (((tmp1 as i64) - (tmp2 as i64)).abs() % 3 == 0
    && ((tmp2 as i64) - (tmp3 as i64)).abs() % 3 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
    
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    var tableC = [[Int]](repeating: [Int](repeating: 0, count: 3), count: 3)
    for i in 0..<3 {
        tableC[i] = readInts()
    }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var isMatch = true
    let diff = [tableC[0][0] - tableC[0][1], tableC[0][1] - tableC[0][2]]
    for i in 1..<3 {
        if tableC[i][0] - tableC[i][1] != diff[0] || tableC[i][1] - tableC[i][2] != diff[1] {
            isMatch = false
        }
    }
    print(isMatch ? "Yes": "No")
}
main()
//  [swift]
import Foundation

let rdArr = [[Int]]()

let cRow1 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c11,c12,c13]をソート
let cRow2 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c21,c22,c31]
let cRow3 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c31,c32,c33]

var aRowS = [Int]()
var aRowT = [Int]()
var aRowU = [Int]()

// print(cRow1)
// print(cRow2)
// print(cRow3)

aRowS.append(abs(cRow1[0] - cRow1[1]))
aRowS.append(abs(cRow2[0] - cRow2[1]))
aRowS.append(abs(cRow3[0] - cRow3[1]))


aRowT.append(abs(cRow1[2] - cRow1[1]))
aRowT.append(abs(cRow2[2] - cRow2[1]))
aRowT.append(abs(cRow3[2] - cRow3[1]))

aRowU.append(abs(cRow1[2] - cRow1[0]))
aRowU.append(abs(cRow2[2] - cRow2[0]))
aRowU.append(abs(cRow3[2] - cRow3[0]))


// print(aRowS)
// print(aRowT)

if aRowS == aRowT || aRowS == aRowU || aRowT == aRowU {
    print("Yes")
} else {
    print("No")
}
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const c = input.map(s => s.split(" ").map(t => Number(t)));
  let result = "No";
  const a1 = 0;
  const b1 = c[0][0] - a1;
  const a2 = c[1][0] - b1;
  const a3 = c[2][0] - b1;
  const b2 = c[0][1] - a1;
  const b3 = c[0][2] - a1;
  if (c[1][1] === a2 + b2 && c[1][2] === a2 + b3 && c[2][1] === a3 + b2 && c[2][2] === a3 + b3) {
    result = "Yes";
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const log = console.log;

const flatNaive = <T>(arrays: T[][]): T[] => [].concat.apply([], arrays);

// ----

function Main(input: string): void {
  const c = input
    .trim()
    .split("\n")
    .map(s => s.split(" ").map(s => parseInt(s)));

  const flatC = flatNaive(c);
  const minC = Math.min(...flatC);
  const maxC = Math.max(...flatC);

  for (let a0 = minC; a0 <= maxC; a0++) {
    // If we know a[0], other values should also be determined
    const b = [c[0][0] - a0, c[0][1] - a0, c[0][2] - a0];
    const a = [a0, c[1][0] - b[0], c[2][0] - b[0]];

    // Validate excluding a[0]
    let valid = true;

    for (let i = 1; i < 3; i++) {
      for (let j = 0; j < 3; j++) {
        if (c[i][j] !== a[i] + b[j]) {
          valid = false;
          break;
        }
      }

      if (!valid) break;
    }

    if (valid) {
      log("Yes");

      return;
    }
  }

  log("No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const c = input.map(s => s.split(" ").map(t => Number(t)));
  let result = "No";
  for (let i = 0; i <= c[0][0]; i++) {
    const a1 = i;
    const b1 = c[0][0] - a1;
    const a2 = c[1][0] - b1;
    const a3 = c[2][0] - b1;
    const b2 = c[0][1] - a1;
    const b3 = c[2][0] - a1;
    if (c[1][1] === a2 + b2 && c[1][2] === a2 + b3 && c[2][1] === a3 + b2 && c[2][2] === a3 + b3) {
      result = "Yes";
      break;
    }
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
print('2018'+input()[4:])
//  [python]
print(input().replace('2017', '2018'))
//  [python]
print( input().replace('2017','2018'))
//  [python]
n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for j in range(y // 5000 + 1):
        k = n - i - j
        if 0 <= k and 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k,sep=" ")
            exit()
print("-1 " + "-1" + " -1")
//  [python]
import sys

S = sys.stdin.readline().strip()
print("2018" + S[5:])
//  [python]
s = list(input())
s[3] = "8"
print(s)
//  [java]
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		char[] str = in.readLine().toCharArray();
		str[3] = '8';
		String s = new String(str);
		System.out.println(s);
	}
}
//  [java]
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        s[3] = '8';
        System.out.println(new String(s));
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String dateString = br.readLine();
            String convertTo2018 = "2018" + dateString.substring(4, 10);

            System.out.println(convertTo2018);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}
//  [java]
import java.util.*;

public class Main{

public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();  
      
      List<Integer> split = new ArrayList<>();
        for (int i = 0; i < n; i++) {
	        int buf = sc.nextInt();
	        split.add(buf);
        }
        
        int tmp = 0;
        int tmp2 = 0;
        int size = split.size();
 
        for(int i = 0; i < size ; i++ ){
            tmp = split.get(i);
            
            for(int j = 0; j < size ; j++){
                tmp2 = split.get(j);
                
                if(tmp2 == tmp && j!= i){
                  split.remove(j);
                  size -= 1;
                  j--;
                }
            }
        }
    if(size == 1){size = 0;}
    System.out.println(size);
  }
}
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replace("7", "8");
        System.out.println(s);
    }
}
//  [java]
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    
    ss[3] = '7';
    	 System.out.println(String.valueOf(ss));
    }
}
//  [cpp]
#include<stdio.h>

int main(){
	
	char s[100];
	
	scanf("%s",s);
	
	s[3]='8';
	
	printf("%s",s);
	
	return 0;
}
//  [cpp]
#include<stdio.h>
int main()
{
    char str[10];
    int i;
    for(i=0;i<=9;i++)
    {
        scanf("%c",&str[i]);
    }
    str[3]='8';
    printf("%s",str);
    return 0;
}
//  [cpp]
#include<stdio.h>
int main()
{
char s[15]={0};
scanf("%s",s);
s[3]='8';
printf("%s",s);
return 0;
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	string s;
	cin >> s;
	s.replace(4, 1, "8");
	cout << s << "\n";
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  s[3]=8;
  cout << s << endl;
  
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  s[3]==8;
  cout << s << endl;
  
}
//  [c]
#include <stdio.h>
int main(void){
    int i;
    char s[10];
    scanf("%s",s);
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    printf("%s\n",s);
    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main()
{
    char S[12],i;
    scanf(" %[^\n]",S);
    for(i=0;i<strlen(S);i++){
        S[0]='2';
        S[1]='0';
        S[2]='1';
        S[3]='8';
    }
    printf("%s",S);




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

int main()
{
    char string[11];
    scanf("%s",string);
    char modified[11];
    modified[0]='2';
    modified[1]='0';
    modified[2]='1';
    modified[3]='8';
    int i;
    for(i=4;i<strlen(string);i++)
    {
        modified[i]=string[i];
    }
    modified[i]='\0';
    printf("%s\n",modified);
    return 0;
}
//  [c]
#include<stdio.h>
int main(){
  char a;
  scanf("%s", &a);
  
  a[3]="8";
  
  printf("%s", a);
  
  return 0;
}
//  [c]
#include<stdio.h>
int main(){
  char a;
  scanf("%s", &a);
  for(int i=0;i<10;i++){
    a[i]=a[i];
    if(i==3)
      a[i]="8";
  }
  
  for(int i=0;i<10;i++){
    printf("%s", a[i]);
  }
  return 0;
}
//  [c]
#include<stdio.h>
int main(){
  char a[10];
  scanf("%s", &a);
  for(int i=0;i<10;i++){
    a[i]=a[i];
    if(i==3)
      a[i]=="8";
  }
  
  for(int i=0;i<10;i++){
    printf("%s", a[i]);
  }
  return 0;
}
//  [javascript]
function main(input) {
  var result = input.replace('2017', '2018');
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  console.log(`2018/${input.slice(5)}`);
}

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

const main = input => {
	console.log(input.replace('2017', '2018'))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function main(input) {
	const args = input.split('\n');
  	const N = parseInt(args[0], 10);
  	let arr = args.slice(1, args.length).map((n) => parseInt(n, 10));
  	
  	const another_arr = [...new Set(arr)];
  
  	console.log(parseInt(another_arr.length, 10));
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const stdin=require("fs").readFileSync("/dev/stdin", "utf8");
const argv=stdin.split("\n");
//const total=Number(argv[0]);
const mochies=argv.slice(1);

//重複しないもちぃのみを抜き出す
const uniqMochies=mochies.filter((a,idx,self)=>self.indexOf(a)==idx);

console.log(uniqMochies.length);
//  [javascript]
function main(input) {
  input = input.trim();
  const a = input.split("").map(Number);
  a[3]=8;
  console.log(a);
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Printf("%s%s%s", s[0:3], "8", s[4:])
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

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

	fmt.Println(strings.Replace(s,"7","8",1))
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

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

	r := strings.Replace(s, "2017", "2018", 1)
	fmt.Println(r)
}
//  [go]
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j <= N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}
//  [go]
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j < N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}
//  [go]
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	fmt.Println(calcMoney(n, y))
}

func calcMoney(n int, yen int) (str string) {
	for x := 0; x <= n; x++ {
		for y := 0; y <= n; y++ {
			z := n - x - y
			if 0 <= z && yen == 10000*x+5000*y+1000*z {
				return fmt.Sprintf("%d %d %d", x, y, z)
			}
		}
	}
	return "-1 -1 -1"
}
//  [ruby]
puts gets.chomp.gsub("2017", "2018")
//  [ruby]
day = gets.chomp.gsub(/2017/,'2018')
puts day
//  [ruby]
st = gets.chomp.split("/")

st[0] = "2018"

print st[0]
print "/"
print st[1]
print "/"
puts st[2]
//  [ruby]
n = gets.to_i
mochis = n.times.map { gets.to_i }
puts mochis.uniq.size
//  [ruby]
arr = gets.strip.split.map(&:to_i).uniq

puts arr.length
//  [ruby]
s=gets.chomp;puts s.gsub(s[3],"8")
//  [rust]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut s = get!(String).chars().collect::<Vec<_>>();
    s[3] = '8';
    println!("{}", s.into_iter().collect::<String>());
}
//  [rust]
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

fn type_of<T>(_: T) -> String{
    let a = std::any::type_name::<T>();
    return a.to_string();
}

#[fastout]
fn main() {
    input! {
        mut s:Chars,
    }
    s[3]='8';
    println!("{}",s.iter().collect::<String>());
}
//  [rust]
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)*}
    };
}

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)*}
    };
}

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")
    };
}
fn main() {
    input! {
    s: chars,
    }
    let mut y = "2018".chars().collect::<Vec<char>>();
    y.extend_from_slice(&s[4..]);
    for i in y {
        print!("{}", i);
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        s: chars,
    };
    let mut ss = s.clone();
    ss[3] = '8';
    println!("{}", ss.iter().collect::<String>())
}
//  [rust]
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();
    let ans = s.replacen("7", "8", 1);
    println!("{}", ans);
}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}
//  [rust]
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();
    let ans = s.replace("7", "8");
    println!("{}", ans);
}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}
//  [swift]
import Glibc
extension String: CollectionType {}

//var inp = readLine()!.split(" ").map { Int($0)! }
var s = readLine()!.split("/")
print("2018/"+s[1]+"/"+s[2])
//  [swift]
print("2018/01/"+readLine()!.characters.split("/").map{String($0)}[2])
//  [swift]
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let ints = readInts()
let n = ints[0]
let sum = ints[1]

func main() {
    for i in 0...n {
        for j in 0...(n - i) {
            for k in 0...(n - i - j) {
                if i * 10_000 + j * 5_000 + k * 1_000 == sum && i + j + k == n {
                    print("\(i) \(j) \(k)")
                    return
                }
            }
        }
    }
    print("-1 -1 -1")
}

main()
//  [swift]
print("2018/01/"+readLine()!.characters.split("/").map{String($0)}[3])
//  [swift]
Gshshshzgsgsgshshshdhdhdhdhdhdhxhxbvvxvxvsgsusudhxbxbxbxbxbxhdhdjdjdhxhxhhdhdhxhxhdhhsshsbdhjxhdhdhdhdhdhd
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.split('\n')[0]

const res = s.replace('2017', '2018')

console.log(res)
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc086 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program): void {
            const [s]: string[] = this.args[0];
            console.log (s.replace('2017', '2018'));

        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc086.Program = new AtCoder.abc086.Program(args);
prg.main();
//  [typescript]
const log = console.log;

const replaceStringAt = (
  str: string,
  index: number,
  length: number,
  replaceValue: string
) => str.substr(0, index) + replaceValue + str.substr(index + length);

// ----

function Main(input: string): void {
  log(replaceStringAt(input, 3, 1, "8"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc086 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program): void {
            const [s]: string[] = this.args[0];
            s.replace('2017','2018');
        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc086.Program = new AtCoder.abc086.Program(args);
prg.main();
//  [python]
n,m=map(int,input().split())
print(max(-1,n-sum(list(map(int,input().split())))))
//  [python]
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
if N - sum(A) >= 0:
     print(N - sum(A))
else:
    print(-1)
//  [python]
# coding: utf-8
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

sum = sum(A)
print(max([N-sum, -1]))
//  [python]
N, M = map(int, input().split())
A = list(map(int, input().split()))
assert len(A) == M
# M個の宿題, それぞれAi日かかる
yasumi = N - sum(A)
if yasumi > 0:
  print(yasumi)
else:
  print(-1)
//  [python]
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

def main(n,m,a):
    days=sum(a)
    if days<n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)
//  [python]

N, M = map(int, input().split())
A = list(map(int, input().split()))

if N - sum(A) > 0:
    print(N-sum(A))
else:
    print(-1)
//  [java]
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            for (int i = 0; i < m; i++) {
                n -= in.nextInt();
            }

            out.println(0 <= n ? n : -1);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            for (int i = 0; i < m; i++) {
                n -= in.nextInt();
            }

            out.println(0 <= n ? n : -1);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}
//  [java]
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int ans = 0:
    for (int i = 0; i < m; i++){
      ans = ans + scan.nextInt();
    }
    if (ans <=n){
      System.out.println(n - ans);
    }else{
      System.out.println(-1);
    }
  }
}
//  [java]
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m];
		int count = 0;
		
		for(int i=0;i<m;i++) {
			a[i] = scan.nextInt();
			count += a[i];
		}
		
		if(n > count) {
			System.out.println(n-count);
		}else {
			System.out.println(-1);
		}

	}

}
//  [java]
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int N = stdIn.nextInt();
    int M = stdIn.nextInt();
    int[] a = new int[N];
    int p = 0;
    int days = N;
   
    for(int i = 1; i<=M; i++){
      a[i] =  stdIn.nextInt();
      p += a[i];
    }
    
    days = N - p;
    
    if(days >= 0){System.out.print(days);}
    else{System.out.print(-1);}
  }
}
//  [cpp]
/*
ID: wangyuxi20040901
TASK:  ()
LANG: C++
DATE: 20200419 20:21:12
*///using CRLF, UTF-8

#include <cstdio>
#include <algorithm>
#include <cstring>
#define pr printf
#define F(i, j, k) for(register ll i = j, kkllkl = k; i <= kkllkl; ++i)
#define G(i, j, k) for(register ll i = j, kkllkl = k; i >= kkllkl; --i)
#define clr(a, v) memset((a), v, sizeof(a))
using namespace std;
typedef long long ll;

#define isd(x) (('0' <= (x) && (x) <= '9') || (x) == '-')
ll rd() {
    ll ans = 0, sign = 1; char c = getchar();
    while(!isd(c)) c = getchar();
    if(c == '-') sign = -1, c = getchar();
    while(isd(c)) ans = (ans << 3) + (ans << 1) + c - '0', c = getchar();
    return sign == 1 ? ans : -ans;
}

/* --------------------------CSYZ1921------------------------- */

const ll N = 10005;
ll n, m, a;

int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    n = rd(); m = rd();
    F(i, 1, m) {
        a = rd();
        n -= a;
    }
    if(n >= 0) pr("%lld\n", n);
    else pr("-1\n");
    return 0;
}
/*
*/
//  [cpp]
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)print(x/10);
	putchar(x%10+48);
}
int main()
{
	int n=read(n),m=read(m);
	while(m--){
		int x=read(x);
		n-=x;
		if(n<0){
			puts("-1");
			return 0;
		}
	}	
	printf("%d\n",n);
	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[m];
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
    {
        cout<<"-1";
    }
    else
    {
        cout<<n-sum;
    }
}
//  [cpp]
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m],sum=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum += a[i];
    }
    int sum2 = n-sum;
    if(sum2 <= n){
            cout<<sum2<<endl;

        }
        else{
            cout<<"-1";
        }

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,M,sum=0,p;
    cin>>N>>M;
    for(int i=0;i<M;i++)
    {
        cin>>p;
        sum+=p;
    }
    cout<<N-sum;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

/*int main()
{
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}*/

/*int main()
{
    string s;
    cin>>s;
    int a=s[0];
    if(a<=90&&a>=65) cout<<s<<endl;
    else
    {
        s[0]=a-32;
        cout<<s<<endl;
    }
    //cout<<a<<endl;
}*/
/*int main()
{
    for(int i=1;i<=100;i++)
    {
        if(i%3==0&&i%5==0) cout<<"FizzBuzz\n";
        else if(i%3==0) cout<<"Fizz\n";
        else if(i%5==0) cout<<"Buzz\n";
        else cout<<i<<endl;
    }
}*/
/*int main()
{
    int n;
    cin>>n;
    if(n%1000==0) cout<<"0\n";
    else
    {
        cout<<1000-n%1000<<endl;
    }
}
*/
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m;i++) {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n) cout<<-1<<endl;
    else if((n-sum)>30) cout<<30<<endl;
    else cout<<n-sum<<endl;
}
//  [c]
#include<stdio.h>
#include<math.h>

int main()
{
  int N,M,A[10000];
  scanf("%d%d",&N,&M);
  int sum=0;
  for(int i=0;i<M;i++){
    scanf("%d",&A[i]);
    sum += A[i];
  }
  if(N >= sum) printf("%d\n",N - sum);
  else printf("-1\n");
  
  
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define mod 10007

int main(void){
    int N,M,A=0;
    scanf("%d %d",&N,&M);
    int x;
    for (int i=0; i<M; i++) {
        scanf("%d",&x);
        A+=x;
    }
    if (N<A) {
        printf("-1\n");
        return 0;
    }
    else{
        printf("%d\n",N-A);
        return 0;
    }
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}
ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

int main(void){
  int n,m;
  INI(n);
  INI(m);
  int a;
  FOR(i,n){
    INI(a);
    m-=a;
  }
  if(m<0){
    PRN(-1);
  }else{
    PRN(m);
  }
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}
ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

int main(void){
  int n,m;
  INI(n);
  INI(m);
  int a;
  FOR(i,n){
    INI(a);
    m-=a;
  }
  PRN(m);
  return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
int n,m,a[10000],sum,i;
sum = 0;
scanf("%d %d",&n,&m);
for(i=0;i<=m;i++){
  scanf("%d",&a[i]);
  sum += a[i];
}
if(n<sum)
	printf("-1");
else
	printf("%d",n - sum);
return 0;
}
//  [javascript]
function Main(input) {
    var tmp = input.split("\n");
    var first = tmp[0].split(" ");
    var A = tmp[1].split(" ");

    var N = parseInt(first[0],10);
    var M = parseInt(first[1],10);

    var sum =0;

    for(var i=0;i<A.length;i++){
        sum = sum + parseInt(A[i],10);
    }

    //console.log(N+"日間夏休み");
    //console.log(M+"個の宿題");
    //console.log(A);
    //console.log(sum);

   
    if(sum <= N){
        console.log(N-sum);
    }else{
        console.log(-1);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = parseInt(arr[0]);
    const M = parseInt(arr[1]);
    const A = line[1].split(" ").map(Number);
    const accum = A.reduce((Ai, x) => Ai + x);
    console.log(N < accum ? -1 : N - accum);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  const arr = input.split('\n');
  const n = arr[0].split(' ')[0];
  const h = arr[1].split(' ').map(x => Number(x));
  const sum = h.reduce((acc, curr) => acc + curr);

  if (sum > n) {
    console.log('-1');
  } else {
    console.log(n - sum);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
/**
 * @param {String} raw_input 入力
 */
function Main(raw_input) {
	const [ first, ...trail ] = raw_input.split("\n");
	const [n, m] = toNumArray(first);
	const aList = toNumArray(trail[0]);

	console.log(n - sum(aList));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

////////// ユーティリティ関数

/**
 * 文字列を数値配列
 * @param {String} str 文字列
 */
function toNumArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => parseInt(s, 10));
}

/**
 * 文字列をVigInt配列に変換する
 * @param {String} str 文字列
 */
function toBitIntArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => BigInt(s));
}

/**
 * 合計を出す
 * @param {Array<Number>} n 数値配列
 */
function sum(n) {
	return n.reduce((a, b) => a + b);
}
//  [javascript]
function main(input){
  input = input.trim();
  var list1 = input.split("\n")[0].split(" ");
  var list = input.split("\n")[1].split(" ");
  for(var i=0; i<list.length; i++){
    list[i] = parseInt(list[i]);
  }
  var nissuu = parseInt(list1[0]);
  var sKei = 0;
  
  for(var i=0; i<list.length; i++){
    sKei += list[i];
  }
  var answer = nissuu - sKei;
  if(answer < 0){answer = -1;}
  console.log(answer);
  
}
main(input);
//  [javascript]
function main(input){
  input = input.trim();
  var list1 = input.split("\n")[0].split(" ");
  var list = input.split("\n")[1].split(" ");
  for(var i=0; i<list.length; i++){
    list[i] = parseInt(list[i]);
  }
  var nissuu = parseInt(list1[0]);
  var sKei = 0;
  
  for(var i=0; i<list.length; i++){
    sKei += list[i];
  }
  var answer = nissuu - sKei;
  if(answer < 0){answer=-1;}
  console.log(nissuu - sKei);
  
}
main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main()  {
	var N, M int
	sum := 0
	_, _ = fmt.Scan(&N, &M)

	inputs := strings.Split(nextLine(), " ")

	for i := 0; i < len(inputs); i++ {
		num, _ := strconv.Atoi(inputs[i])
		sum += num
	}

	tmp := N - sum

	if tmp >= 0{
		fmt.Println(tmp)
	}else{
		fmt.Println(-1)
	}
}