jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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! {
        N: usize,
        S: [String; N],
    }
    use std::collections::HashSet;
    let mut set = HashSet::new();
    for i in 0..N {
        set.insert(S[i].clone());
    }
    if set.len() == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub 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")
}

use std::collections::HashSet;

fn main() {
    let n: usize = read();
    let mut hs: HashSet<char> = HashSet::new();

    for _ in 0..n {
        let ni = read::<String>().chars().nth(0).unwrap();
        hs.insert(ni);
    }
    println!(
        "{}",
        match hs.len() {
            3 => "Three",
            4 => "Four",
            _ => "",
        }
    )
}
//  [rust]
extern crate core;

use std::io::{self, Read};
use std::collections::HashSet;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split("\n")
        .nth(1)
        .unwrap()
        .split_whitespace()
        .map(|x| x.to_string())
        .collect::<HashSet<_>>();
    if list.len() == 3 { "Three" } else { "Four" }.to_string()
}

#[test]
fn test() {
    let tests = vec![
        (
            "6
G W Y P Y W",
            "Four",
        ),
        (
            "9
G W W G P W P G G
",
            "Three",
        ),
        (
            "8
P Y W G Y W Y Y",
            "Four",
        ),
    ];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}
//  [rust]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		s: [char; n],
	}

	for i in 0..n {
		if s[i] == 'Y' {
			println!("Four");
			return;
		}
	}
	println!("Three");
}
//  [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)!}
}

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

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

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

let _ = readLine()
let arare = readStringSplit(by: " ")
print(arare.contains("Y") ? "Four" : "Three")
//  [swift]
import Foundation
func readStrings() -> [String] { readLine()!.split(separator: " ").map { String($0) } }

_ = readLine()
let si = readStrings()
print(si.contains("Y") ? "Four" : "Three")
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

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

const ans = () => {
  let is4 = false

  for (let i = 0; i < n; i++) {
    if (s[i] === 'Y') {
      is4 = true
    }
  }

  console.log(is4 ? 'Four' : 'Three')
}

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

const n = Number(input.split('\n')[0]);

const colorArr = input.split('\n')[1].split(' ');

const include = (arr, x) => {
  if (arr.indexOf(x) === -1) {
    return false
  } else {
    return true;
  }
};

if (include(colorArr, 'Y')) {
  console.log('Four');
} else {
  console.log('Three');
}
//  [typescript]

export const main = (input: string) => {
  const lines = input.split('\n')
  const cols = lines[1].split(' ')
  const flags = {
    P: false, W: false, G: false, Y: false
  }
  let count = 0
  cols.forEach((elem) => {
    if (flags[elem] === false) {
      count = count + 1
      flags[elem] = true
    }
  })
  console.log(`${count === 3 ? 'Three' : 'Four'}`)
}

if (process.env.NODE_ENV !== 'test') {
  main(require('fs').readFileSync('/dev/stdin', 'utf8'))
}
//  [typescript]
import { readFileSync } from "fs";

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

const main = (input: string[][]) => {
  const bag = input[1];

  return new Set(bag).size === 3 ? "Three" : "Four";
};

console.log(main(read()));
//  [typescript]
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});

reader.on("close", function() {
  var inputs: String[] = lines[1].split(" ");
  switch (new Set(inputs).size) {
    case 3:
      console.log("Three");
      break;
    case 4:
      console.log("Four");
      break;
  }
});
//  [typescript]
import * as fs from "fs";
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split(/\n/);
const hinaArare = input[1].split(/\s/);
const ret = hinaArare.filter((val, index) => hinaArare.indexOf(val) == index);
console.log(ret.length == 3 ? "Three" : "Four");
//  [python]
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	for i in range(100000):
		tmp = i * 1000
		#print(tmp)
		ans = tmp-N
		if ans >= 0:
			print(ans)
			sys.exit()

	print(N)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()
//  [python]
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    if n%1000!=0:
        print(1000-n%1000)
    else:
        print(0)



if __name__ == "__main__":

    main()
//  [java]
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int a = sc.nextInt();
        int total = (a + 999) / 1000 * 1000;
        pw.println(total - a);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n % 1000 == 0){
			System.out.println("0");
		} else {
			System.out.println(1000 - n % 1000);
		}
	}

}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ms(a ,value) memset(a ,value,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define N 20000000
class Triplet{
	public:
		int x , y , z;	
};
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
const int mod = 1e9+7;
vector <int> adj[N];
string str;
map <int,int> freq;
const double PI=3.1415926535897;
typedef long long int ll;

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

	if(n%1000==0){
		cout<<"0"<<endl;
		return 0;
	}

	int ans = 1000*ceil(n/1000+1)-n;
	cout<<ans<<endl;
	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x;
string s,t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	while(n > 0) {
		n-=1000;
	}
	cout<<-n;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  
  int input = 0;
  scanf("%d", &input);
  int change = input % 1000; 
  if (change > 0) {
    change = 1000 - change; 
    printf("%d\n", change);
  } else {
      printf("%d\n", change);
  }
  
  
  return 0; 
}
//  [c]
#include <stdio.h>
#include <math.h>
 
int main(){
  int n;
  scanf("%d\n",&n);
  if(n%1000==0){
    printf("%d",0);
  } else {
    printf("%d\n",1000-n%1000);
  }
  return 0;
}
//  [c]
#include<stdio.h>

int main()
{
	int n;
	int k = 0;
	scanf("%d",&n);
	
	while (n > k) {
		k = k + 1000;
	}
	
	printf("%d\n",k-n);
	
	return 0;
}
//  [javascript]
function main(input) {
    const n = parseInt(input, 10);
    console.log(parseInt((n+999)/1000)*1000-n);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// let input = "3000";

function main(input){
  input = input.trim();
  input = parseInt(input);
  let amari = input%1000;
  let answer;
  
  if(amari===0){
    answer = 0;
  }else{
    answer = 1000 - amari;
  }
  console.log(answer);
}
main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
function Main(input) {
    const hyaku = Number(input)%1000;
    console.log(hyaku === 0 ? 0: 1000-hyaku);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1000; ; i += 1000 {

		if n > i {
			continue
		}

		fmt.Println(i - n)
		break
	}
}
//  [go]
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	N := readint()
	for i := 0; i < 1000; i++ {
		if i*1000 >= N {
			fmt.Println(i*1000 - N)
			break
		}
	}
}

func readline() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
if n % 1000 == 0
  puts 0
else
  puts 1000 - n % 1000
end
//  [ruby]
n = gets.to_i

if n % 1000 == 0
  p 0
else
  p 1000 - (n % 1000)
end
//  [ruby]
n = gets.to_i
ans = 1000 - (n % 1000)
ans = 0 if ans == 1000
puts ans
//  [swift]
import Foundation

struct Mojiretu: Equatable {
    var characters: [Int]
    
    init(characters: [Int]) {
        
        self.characters = characters
    }
    init(_ slice: ArraySlice<Int>) {
        
        self.characters = Array(slice)
    }
}

extension Mojiretu {
    struct KeyCode {
        static let space = 0x20
        static let lf = 0x0A
    }
    
    static func readLine() -> Mojiretu {
        .init(characters:
            (0...)
                .lazy
                .map { _ in Int(getchar()) }
                .prefix { $0 != KeyCode.lf }
        )
    }
    
    static func readToken() -> Mojiretu {
        .init(characters:
            (0...)
                .lazy
                .map { _ in Int(getchar()) }
                .prefix { $0 != KeyCode.lf && $0 != KeyCode.space }
        )
    }
    
    var tokens: [Mojiretu] {
        characters
            .split { $0 == KeyCode.lf || $0 == KeyCode.space }
            .map(Mojiretu.init)
    }
}

struct MojiretuCharacterIterator: IteratorProtocol {
    private var iter: IndexingIterator<Array<Int>>
    
    init(_ Mojiretu: Mojiretu) {
        iter = Mojiretu.characters.makeIterator()
    }
    
    mutating func next() -> Character? {
        guard let i = iter.next() else { return nil }
        
        return Unicode.Scalar(i).map(Character.init)
    }
}

extension Mojiretu: Sequence {
    
    func makeIterator() -> MojiretuCharacterIterator {
        MojiretuCharacterIterator(self)
    }
}


extension Mojiretu {
    var integer: Int {
        characters
            .lazy
            .map { $0 - Int("0".utf8.first!) }
            .prefix { (0...9) ~= $0 }
            .reduce(0) { r, i in r * 10 + i }
    }
}


let n = Mojiretu
  .readLine()
  .integer

print(
  (1...)
    .lazy
    .map { $0 * 1000 - n }
    .prefix { $0 < 1000 }
    .last!
)
//  [swift]
import Foundation

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

func main(){
    let value = Int(readLine()!)!
    if value % 1000 == 0 {
        print(0)
        return
    }
    print(abs(value % 1000 - 1000))
}

main()
//  [swift]
import Foundation

let n = Int(readLine()!)

let p = n!%1000

if p != 0 {
    print(1000-p)
} else {
    print(0)
}
//  [typescript]
import { readFileSync } from 'fs'

function main(input: string[]) {
  let n = Number(input)
  let ans = 1000 - n % 1000
  if (ans === 1000) ans = 0
  console.log(ans)
}

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

reader.on('line', function (line: any) {
  lines.push(line);
});
reader.on('close', function () {
    main(lines)
});
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let 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 () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let n = parseInt(lines[0])

    console.log((1000 - (n % 1000)) % 1000)
});
//  [typescript]
const lines = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  let N = +lines[0];

  while (N >= 1000) {
    N -= 1000
  }

  if (N > 0) {
    N = 1000 - N
  }

  console.log(N);

});
//  [python]
from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    mod = 10**9 + 7
    h, w = map(int, input().split())

    dp = [0] * (w + 1)
    dp[1] = 1
    for _ in range(h):
        a = input()
        for i in range(w):
            if a[i] == '#':
                dp[i+1] = 0
            else:
                dp[i+1] += dp[i]
                dp[i+1] %= mod

    print(dp[w])

main()
//  [python]
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


H, W = na()

A_array = [ns() for _ in range(H)]

mod = 10 ** 9 + 7

ans = [[0] * W for _ in range(H)]

ans[0][0] = 1
for i in range(1, W):
    if A_array[0][i] == "#":
        continue
    ans[0][i] = ans[0][i-1]

for i in range(1, H):
    if A_array[i][0] == "#":
        continue
    ans[i][0] = ans[i-1][0]


for i in range(1, H):
    for j in range(1, W):
        if A_array[i][j] == "#":
            continue
        ans[i][j] = (ans[i-1][j] + ans[i][j-1]) % mod

print(ans[H-1][W-1])
//  [python]
import sys
input = sys.stdin.readline

h, w = map(int,input().split())
C = [input() for i in range(h)]
mod = 10**9 + 7

D = [[0] * w for i in range(h)]
D[0][0] = 1
for i in range(h):
    for j in range(w):
        if (i!=0 or j!=0) and C[i][j]==".":
            if i-1 >= 0:
                D[i][j] += D[i-1][j]
            if j-1 >= 0:
                D[i][j] += D[i][j-1]
            D[i][j] %= mod
print(D[-1][-1])
//  [python]
def add(a, b):
    mod = 1e9+7
    c = a + b
    if c >= mod:
        c -= mod
    return c

H, W = [int(x) for x in input().split()]

sl = [input() for _ in range(H)]

dp = [[0 for _ in range(W)] for _ in range(H)]

dp[0][0] = 1 

for i in range(H):
    for j in range(W):
        for frm in [[i-1, j], [i, j-1]]:
            r, c = frm
            if r >= 0 and c >= 0 and sl[r][c] != '#':
                dp[i][j] = add(dp[i][j], dp[r][c])

print(int(dp[H-1][W-1]))


"""
using ll = long long; 
int add(int a, int b) {
    int MOD = 1e9 + 7;
    return (a + b) % MOD;
}
int main() {
    int H;
    int W;
    scanf("%d%d\n", &H, &W);
    vector<vector<int>> dp(H, vector<int>(W));
    vector<vector<bool>> is_wall(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        scanf("\n");
        for (int j = 0; j < W; j++) {
            char ch;
            scanf("%c", &ch);
            //cout << i << " " << j << " " << ch << endl;
            if (ch == '#') {
                is_wall[i][j] = true;
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            //cout << i << " " << j << " " << is_wall[i][j] << endl;
            if (!is_wall[i][j]) {
                if (i - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i-1][j]);
                }
                if (j - 1 >= 0) {
                    dp[i][j] = add(dp[i][j], dp[i][j-1]);
                }    
            }
        }
    }    
	printf("%d\n", dp[H-1][W-1]);
	return 0;
}



"""
//  [python]
######################################################
############Created by Devesh Kumar###################
#############devesh1102@gmail.com####################
##########For CodeForces(Devesh1102)#################
#####################2020#############################
######################################################
import sys
input = sys.stdin.readline

# import sys
import heapq 
import copy
import math
import decimal
# import sys.stdout.flush as flush
# from decimal import *
#heapq.heapify(li) 
#
#heapq.heappush(li,4) 
#
#heapq.heappop(li)
#
# &	Bitwise AND Operator	10 & 7 = 2
# |	Bitwise OR Operator	10 | 7 = 15
# ^	Bitwise XOR Operator	10 ^ 7 = 13
 
# <<	Bitwise Left Shift operator	10<<2 = 40
# >>	Bitwise Right Shift Operator
# '''############ ---- Input Functions ---- #######Start#####'''
 

def inp():
	return(int(input()))
def inlt(): 
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(list(s[:len(s) - 1]))
def insr2():
	s = input()
	return((s[:len(s) - 1]))
def invr():
	return(map(int,input().split()))
 ############ ---- Input Functions ---- #######End
 # #####   

def pr_list(a):
	print(*a, sep=" ")
def main():
	# tests =  inp()
	tests = 1
	mod = 1000000007
	limit = 10**18
	ans = 0
	m = [0,-1]
	for test in range(tests):
		[n,m] = inlt()
		grid = []
		for i in range(n):
			grid.append(insr())
		dp = [[0 for j in range(m)] for i in range(n)]
		dp[-1][-1] = 1
		move = {}
		move[(n-1,m-1)] =1
		while(move != {}):
			n_move = {}
			# print(dp)
			for i in move:
				
				if i[0]-1 >=0 and grid[i[0]-1][i[1]] == ".":
					dp[i[0]-1][i[1]] = (dp[i[0]-1][i[1]]+ dp[i[0]][i[1]])%mod
					n_move[ (i[0]-1,i[1]) ] =1
				if i[1]-1 >=0 and grid[i[0]][i[1]-1]  == "." :
					dp[i[0]][i[1]-1] = (dp[i[0]][i[1]-1]+ dp[i[0]][i[1]])%mod
					n_move[ (i[0],i[1]-1) ] =1
			move = n_move
		print(dp[0][0])


if __name__== "__main__":
	main()
//  [python]
import sys
sys.setrecursionlimit(10**8)

h,w=map(int,input().split())
a=[]
dp={}
dp[(h-1,w-1)]=1
for i in range(h):
	a.append(list(input()))

def foo(i,j):
	if i>=h or j>=w:
		return 0
	if (i,j) in dp:
		return dp[(i,j)]
	ans=0
	if i+1<h and a[i+1][j]=='.':
		ans+=foo(i+1,j)
	if j+1<w and a[i][j+1]=='.':
		ans+=foo(i,j+1)
	dp[(i,j)]=ans%(1e9+7)
	return dp[(i,j)]

print(int(foo(0,0)))
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		String matrix[][] = new String[h][w];
		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

		int dp[][] = new int[h][w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (matrix[i][j].equals("#")) {
					dp[i][j] = 0;
				} else {
					if (i - 1 < 0 && j - 1 < 0) {
						dp[i][j] = 1;
					} else if (i - 1 < 0) {
						dp[i][j] = (dp[i][j - 1]) % 1000000007;
					} else if (j - 1 < 0) {
						dp[i][j] = (dp[i - 1][j]) % 1000000007;
					} else {
						dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;
					}
				}
			}
		}

		System.out.println((dp[h - 1][w - 1]) % 1000000007);
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String[] fields = input.nextLine().split(" ");
		int H = Integer.parseInt(fields[0]);
		int W = Integer.parseInt(fields[1]);
		String[][] grid = new String[H][W];
		for (int i = 0; i < grid.length; i++) {
			String x = input.nextLine();
			for (int j = 0; j < x.length(); j++) {
				grid[i][j] = x.substring(j,j+1);
			}
		}
		System.out.println(uniquePathsWithObstacles(grid));
	}
	public static int uniquePathsWithObstacles(String[][] obstacleGrid) {
        int[][] dp = new int[obstacleGrid.length][obstacleGrid[0].length];
        int mod = 1000000007;
        if (obstacleGrid[0][0].equals("#")) return 0;
        dp[0][0] = 1;
        for (int i = 1; i < obstacleGrid.length; i++) {
        	if (!obstacleGrid[i][0].equals("#")) dp[i][0] = 1;
        	else break;
        }
        for (int i = 1; i < obstacleGrid[0].length; i++) {
        	if (!obstacleGrid[0][i].equals("#")) dp[0][i] = 1;
        	else break;
        }
        for (int i = 1; i < obstacleGrid.length; i++) {
        	for (int j = 1; j < obstacleGrid[0].length; j++) {
        		if (!obstacleGrid[i][j].equals("#")) dp[i][j] = dp[i-1][j]+dp[i][j-1];
        		else dp[i][j] = 0;
        		if (dp[i][j]>mod) dp[i][j]-=mod;
        	}
        }
		return dp[obstacleGrid.length-1][obstacleGrid[0].length-1];
    }
}
//  [cpp]
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please
 
const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
 
 
	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);
 
	ll dp[1001];
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();
 
	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);
 
	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	vector<ll> dp(W);
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();

	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	ll dp[1001];
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();

	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const int MAXN = 1e3+5, MOD = 1e9+7;
ll dp[MAXN][MAXN];
string mat[MAXN];

int n, m;

ll f(int i, int j){
    if(i==n-1 && j==m-1) return 1LL;
    if(i>=n || j>=m || mat[i][j] == '#') return 0;
    if(~dp[i][j]) return dp[i][j];
    return dp[i][j] = (f(i+1, j)%MOD + f(i, j+1)%MOD)%MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);



    cin >> n >> m;
    for (int i=0; i<n; i++)
        cin >> mat[i];

    memset(dp, -1, sizeof dp);

    cout << f(0, 0) << "\n";

    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            debug(dp[i][j])
        }
    }



    return 0;
}

/*
1
9 3
111100000
 */
//  [cpp]
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{
	return (M*m) / GCD(max(M, m), min(M, m));

}


	
int h, w;
char arr[1002][1002];
map<pair<int, int>, ll>mp;
ll solve(ll i, ll j)
{
	if (arr[i][j] == '#')
		return mp[{i, j}] = 0;
	if (i == h - 1&&j==w-1)
		return 1;
	if (i >= h||j>=w)
		return 0;
	if (mp[{i, j}] != -1)
		return mp[{i, j}];
	return mp[{i, j}] = ((solve(i + 1, j) % (1000000007)) + solve(i, j + 1) % (1000000007)) % (1000000007);
}


int main()
	{
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> arr[i][j];
			mp[{i, j}] = -1;
		}
	}
	cout << solve(0,0);
	}
//  [cpp]
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
const int mod = 1e9+7;
int R, C;
char gr[1001][1001];
vector<vector<LL> > dp(1001, vector<LL>(1001, 0));
map<pair<int, int>, int> fr;
int dr[] = {1, 0};
int dc[] = {0, 1};
bool vd(int r, int c){
    return !(r < 0 || r >= R || c < 0 || c >= C || gr[r][c] == '#');
}
void bfs(int r, int c){
    queue<pair<int, int> > q;
    q.push(mp(r, c));
    fr[mp(r, c)] = 1;
    while (!q.empty()){
        r = q.front().x;
        c = q.front().y;
        //cout << r << ' ' << c << endl;
        fr[mp(r, c)]--;
        q.pop();
        if (fr[mp(r, c)] != 0)
            continue;
        for (int i = 0; i < 2; ++i){
            int nr = r+dr[i], nc = c + dc[i];
            if (vd(nr, nc)){
                q.push(mp(nr, nc));
                if (fr.find(mp(nr, nc)) == fr.end())
                    fr[mp(nr, nc)] = 1;
                else
                    fr[mp(nr, nc)] ++;

                dp[nr][nc] = (dp[nr][nc] + dp[r][c])%mod;
            }
        }
    }
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    scanf("%d %d\n", &R, &C);
    for (int i = 0; i < R; ++i){
        for (int j = 0; j < C; ++j){
            scanf("%c", &gr[i][j]);
        }
        if (i != R-1)
            scanf("\n");
    }
//    for (int i = 0; i < R; ++i)
//        for (int j = 0; j < C; ++j)
//            printf("%s\n", gr[i]);
    dp[0][0] = 1;
    bfs(0,0);
    cout << dp[R-1][C-1];
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */
//  [c]
#include<stdio.h>
#include<stdlib.h>

void run(void){
  const int mod=1000000007;
  int h,w;
  scanf("%d%d",&h,&w);
  char *s=(char *)calloc(w+1,sizeof(char));
  int *dp=(int *)calloc(w+1,sizeof(int))+1;
  dp[0]=1;
  while(h--){
    scanf("%s",s);
    for(int i=0;i<w;i++){
      if(s[i]=='#'){
	dp[i]=0;
      } else {
	dp[i]+=dp[i-1];
	if(dp[i]>=mod) dp[i]-=mod;
      }
    }
  }
  printf("%d\n",dp[w-1]);
}

int main(void){
  run();
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 1000000007

long dp[1005][1005];
char a[1005][1005];

int def(int H,int W);

int main(void){
  int H,W,i,j;
  char str[1100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  H=atoi(p);
  p=strtok(NULL," \n");
  W=atoi(p);
  
  for(i=0;i<H;i++){
    fgets(str,sizeof(str),stdin);
    strcpy(a[i],str);
  }
  
  def(H,W);
  
  printf("%ld\n",dp[H-1][W-1]);
  
  return 0;
}

int def(int H,int W){
  int i,j;
  
  dp[0][0]=1;
  
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(a[i][j]=='.'){
        if(i>0 && j>0){
          dp[i][j]=dp[i-1][j]+dp[i][j-1];
          dp[i][j]%=INF;
        }else if(i==0 && j>0){
          dp[i][j]=dp[i][j-1];
          dp[i][j]%=INF;
        }else if(i>0 && j==0){
          dp[i][j]=dp[i-1][j];
          dp[i][j]%=INF;
        }
      }
    }
  }
  
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 h, w;
  scanf ("%" SCNi32 "%" SCNi32, &h, &w);
  i32 *dp = ALLOC (w + 1, i32) + 1;
  char *s = ALLOC (w + 1, char);
  const i32 mod = 1000000007;
  dp[0] = 1;
  while (h--) {
    scanf ("%s", s);
    for (i32 i = 0; i < w; ++i) {
      if (s[i] == '#') {
        dp[i] = 0;
      } else {
        dp[i] = (dp[i] + dp[i - 1]) % mod;
      }
    }
  }
  printf ("%" PRIi32 "\n", dp[w - 1]);
}

int main (void) {
  run();
  return 0;
}
//  [c]
#include <string.h>
#include <stdio.h>
typedef long long ll;
ll m = 1000000007;
char mat[1005][1005];
int vis[1005][1005], memo[1005][1005];

ll solve(int i, int j)
{
    if(vis[i][j])
        return memo[i][j];
    vis[i][j]++;
    if(i==1 && j>1)
        return memo[i][j] = solve(i, j-1);
    if(i>1 && j==1)
        return memo[i][j] = solve(i-1, j);
    if(i==1 && j==1)
        return memo[i][j] = 1;
    
    return memo[i][j] = (solve(i-1, j) + solve(i, j-1))%m;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    memset(vis, 0, sizeof(vis));
    memset(memo, 0, sizeof(memo));
    int h, w;
    char dummy;
    scanf("%d %d", &h, &w);
    scanf("%c", &dummy);
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
            scanf("%c", &mat[i][j]);
        scanf("%c", &dummy);
    }
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(mat[i][j] == '#')
                vis[i][j]++;
        }            
    }
    printf("%lld\n", solve(h, w));
    // for(int i=1; i<=h; i++)
    // {
    //     for(int j=1; j<=w; j++)
    //     {
    //         printf("%d ", memo[i][j]);
    //     }            
    //     printf("\n");
    // }
    return 0;
}
//  [c]
#include <stdio.h>

long long dp[1003][1003];
const long long m=1000000007;

long long solve(long long i,long long j)
{
  if(i==0 && j==0) return dp[i][j]=1;
  if(dp[i][j]!=-1) return dp[i][j];
  else if(i==0) return dp[i][j]=solve(i,j-1);
  else if(j==0) return dp[i][j]=solve(i-1,j);
  else return dp[i][j]=(solve(i-1,j)+solve(i,j-1))%m;
}

int main()
{
  char c;
  long long h,w,ans;
  for(int i=0;i<1003;i++)
  {
    for(int j=0;j<1003;j++)
      dp[i][j]=-1;
  }
  scanf("%lld%lld",&h,&w);
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      scanf(" %c",&c);
      if(c=='#')
        dp[i][j]=0;
    }
  }
  ans=solve(h-1,w-1);
  printf("%lld\n",ans);
  return 0;
}
//  [c]
#include <stdio.h>



#define MOD 1000000007
typedef long long int ll;

//dp solution
ll grid1_dp( ll H, ll W, ll cols, char arr[][cols]){

	ll dp[H][W];
	
	for(int h=0;h<H;h++){
		for(int w=0;w<W; w++){
		
			if(h<0||w<0) dp[h][w]=0;

			else if(h==0 && w==1 && arr[h][w]=='.')
				dp[h][w]=1;
			else if(h==0 && w==1 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(h==1 && w==0 && arr[h][w]=='.')
				dp[h][w]=1;
				
			else if(h==1 && w==0 && arr[h][w]=='#')
				dp[h][w]=0;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h-1][w]%MOD;
			
			else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]=dp[h][w-1]%MOD;
			
			else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
				dp[h][w]= (dp[h-1][w]%MOD+dp[h][w-1]%MOD)%MOD;
				
				
			else if(h==0 && w-1>=0 && arr[h][w]=='.'){
				dp[h][w]=dp[h][w-1]%MOD;
			}
			
			else if(h-1>=0 && w==0 && arr[h][w]=='.'){
				dp[h][w]=dp[h-1][w]%MOD;
			}
			else dp[h][w]=0;
			
		}
	
	}
	
	return dp[H-1][W-1];

}



//recursive solution
ll grid1( ll h, ll w, ll cols, char arr[][cols]){
	if(h<0||w<0) return 0;

	else if(h==0 && w==1 && arr[h][w]=='.')
		return 1;
	else if(h==0 && w==1 && arr[h][w]=='#')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='.')
		return 1;
		
	else if(h==1 && w==0 && arr[h][w]=='#')
		return 0;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='#' && h-1>=0 && w-1>=0)
		return (grid1(h-1, w, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='#' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return (grid1(h, w-1, cols, arr))%MOD;
	
	else if(arr[h-1][w]=='.' && arr[h][w-1]=='.' && h-1>=0 && w-1>=0)
		return ((grid1(h-1, w,cols, arr))%MOD+(grid1( h, w-1, cols, arr))%MOD)%MOD;
		
		
	else if(h==0 && w-1>=0 && arr[h][w]=='.'){
		return (grid1( h, w-1, cols, arr))%MOD;
	}
	
	else if(h-1>=0 && w==0 && arr[h][w]=='.'){
		return (grid1( h-1, w, cols, arr))%MOD;
	}
	else return 0;
}

int main(){
	ll h, w,cols;
	scanf("%lld%lld", &h, &w);
	char arr[h][w];
	cols = w;
	ll i=0,j=0;
	char c;
	while(i<h){
		j=0;
		while(j<w){
			
			scanf("%c", &c);
			
			if(c!='\n'){
				arr[i][j]=c;
				j++;
			}
			
			
		}
		i++;
		
	}
			
	
			
	printf("%lld\n", grid1_dp( h, w,cols,  arr));
	

}
//  [javascript]
console.log(function(args){
  const map = args.trim().split('\n');
  const [H,W] = map.shift().split(' ').map( v=>v|0 );
  const dp = Array(H).fill(0).map( r=>Array(W).fill(0) );
  dp[0][0] = 1;
  for ( let h = 0; h < H; h++ ) {
    for ( let w = 0; w < W; w++ ) {
      if ( map[h][w] === '#' ) continue;
      if ( h > 0 ) dp[h][w] = (dp[h][w] + dp[h-1][w]) % (1e9+7);
      if ( w > 0 ) dp[h][w] = (dp[h][w] + dp[h][w-1]) % (1e9+7);
    }
  }
  return dp[H-1][W-1].toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
'use strict';
(function(input){
  input=input.trim().split(/\n/);
  var firstLine=input[0].split(/\s+/).map(x=>x-0);
  const H=firstLine[0],W=firstLine[1];
  const K=Math.pow(10,9)+7;
  input.shift();
  const dp=new Array(H+1).fill(0).map(x=>new Array(W+1).fill(0));
  dp[0][1]=1;
  for(let i=1;i<=H;i++){
    for(let j=1;j<=W;j++){
      let p=(input[i-1][j-1]==='.');
      dp[i][j]=p?((dp[i-1][j]+dp[i][j-1])%K):0;
    }
  }
  console.log(dp[H][W]);
})(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var mod = Math.pow(10,9)+7;
  var H = parseInt(input[0].split(" ")[0]);
  var W = parseInt(input[0].split(" ")[1]);
  input.shift();
  var a = input.map(i => i.split(""));
  var map=new Array(H);
  for(var i=0;i<H;i++){
    var tmp=new Array(W);
    map[i]=tmp;
  }
  input.pop();
  for(var i=0;i<H;i++){
    for(var j=0;j<W;j++){
      if(a[i][j]=="."){
        if(i==0){
          if(j==0){
            map[i][j]=1;
          }else{
            map[i][j]=map[i][j-1];
          }
        }else if(j==0){
          map[i][j]=map[i-1][j];
        }else{
          map[i][j]=(map[i-1][j]+map[i][j-1])%mod;
        }
      }else{
        map[i][j]=0;
      }
    }
  }
  var ans=map[H-1][W-1];

  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));