jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    ll l, r;

    scanf("%lld %lld", &l, &r);

    int min = 2018;
    if((r - l) >= 2019){
        min = 0;
    }else{
        for(int i = l; i < r; ++i){
            for(int j = i + 1; j <= r; ++j){
                if(((i * j) % 2019) < min){
                    min = (i * j) % 2019;
                }
            }
        }
    }

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

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

int main(){
	long long int l,r,i,j,amari = 2018;
	scanf("%lld %lld",&l,&r);
	for(i = l; i < r; i++){
		if( (i * (i + 1) % 2019) < amari){
			amari = i * (i + 1) % 2019;
		}
	}
	printf("%lld",amari);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int l,r;
  scanf("%d%d",&l,&r);

  if(r-l>2020){
    printf("0\n");
    return 0;
  }

  int ans=3000;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<=r;j++){
      
      int now=i%2019*j%2019;

      chmin(&ans,now);
    }
  }

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

  return 0;
}
//  [javascript]
'use strict'
function main(i) {
  i = i.trim().split(' ')
  const Y = 2019
  const R = Number(i[1])
  const L = Number(i[0])
  let ans = Y - 1;

  if (L * R > Y){
    if (R - L < Y) {
      const LY = L % Y;
      const RY = R % Y;

      for(let i = LY; i < RY; i++){
        for(let j = i + 1; j <= RY; j++){
          let n = (i * j) % Y
          if (n < ans) ans = n
          if (ans === 0) break
        }
        if (ans === 0) break
      }
	    console.log(ans);
    } else {
      console.log(0);
    }
  } else {
    console.log(L * (L+1));
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  var L = parseInt(input.split(" ")[0]);
  var R = parseInt(input.split(" ")[1]);
  var min = 2019;
  if((R - L) >= 2019){
     console.log(0);
    	return;
     }
  L = L % 2019;
  R = R % 2019;
  for(var i = L; i < R; i++){
    if(i % 2019 == 0){
       console.log(0);
    	return;
    }
    for(var j = i + 1; j <= R; j++){
      if(j % 2019 == 0){
         console.log(0);
    	return;
         }
      var cal = (i * j) % 2019;
      if(min > cal){
         min = cal;
        if(min == 0){
           console.log(min);
          return;
           }
      }
    }
  }
  console.log(min);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = (inputs) => {
  var TW = 2019;
  var L = inputs[0].split(" ")[0]-0;
  var R = inputs[0].split(" ")[1]-0;
  var mods = [];
  var thflg = false;  // 3
  var mnsflg = false; // 673
  for(var i=L;i<=R;i++){
    var val = i%TW;
    mods.push(i);
    if(val == 0){
      console.log(0);
      return;
    }else if(val == 3){
      thflg = true;
    }else if(val == 673){
      mnsflg = true;
    }
    if(thflg && mnsflg){
      console.log(0);
      return;
    }
  }
  var ans = TW;
  for(var i=0;i<mods.length;i++)
  for(var j=i+1;j<mods.length;j++){
    ans = Math.min(ans, ((mods[i]%TW)*(mods[j]%TW))%TW);
  }
  console.log(ans);

}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const L=input[0].split(' ')[0]-0;
  const R=input[0].split(' ')[1]-0;
  if(R-L>3000){
    console.log(0);
    return;
  }
  var ans=Infinity;
  for(var i=L;i<R;i++){
    for(var j=i+1;j<=R;j++){
      ans=Math.min(ans,i*j%2019);
    }
  }
  console.log(ans);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const L=input[0].split(' ')[0]-0;
  const R=input[0].split(' ')[1]-0;
  var min=L%2019;
  var max=R%2019;
  if(max<=min){
    max+=2019;
  }
  var ans=Infinity;
  for(var i=min;i<max;i++){
    for(var j=i+1;j<=max;j++){
      ans=Math.min(ans,i*j%2019);
    }
  }
  console.log(ans);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [L, R] = nextIntArray()
    let min = 2018
    for(let i = L; i<R; i++){
        for(let j = i+1; j<=R; j++){
            let div = i*j%2019
            if(div == 0){
                console.log(0)
                return
            } 
            min = Math.min(min, div)
        }
    }
    console.log(min)
}
Main()
//  [go]
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	var min int
	ans := 9999

	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			min = i * j % 2019
			if min < ans {
				ans = min
				if ans == 0 {
					break
				}
			}
		}
		if ans == 0 {
			break
		}
	}

	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	var min int
	ans := 2020

	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			min = i * j % 2019
			if min < ans {
				ans = min
			}
			if min == 0 {
				fmt.Println(0)
				return
			}
		}
	}

	fmt.Println(ans)
}
//  [go]
package main

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

func main() {
	L, R := ReadInt(), ReadInt()
	if R-L+1 >= 2019 {
		fmt.Println(0)
		return
	}
	if L%2019 > R%2019 {
		fmt.Println(0)
		return
	}

	min := 2018
	for i := L % 2019; i < R%2019; i++ {
		v := (i * (i + 1)) % 2019
		if v < min {
			min = v
		}
	}
	fmt.Println(min)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [go]
package main

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

func main() {
	L, R := ReadInt(), ReadInt()
	if R-L+1 >= 2019 {
		fmt.Println(0)
		return
	}
	if L%2019 < R%2019 {
		L %= 2019
		fmt.Println((L * (L + 1)) % 2019)
	} else {
		fmt.Println(0)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [go]
package main

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

func main() {
	L, R := ReadInt(), ReadInt()
	if R-L+1 >= 2019 {
		fmt.Println(0)
		return
	}
	if L%2019 < R%2019 {
		fmt.Println(L * (L + 1) % 2019)
	} else {
		fmt.Println(0)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [ruby]
l, r = gets.split.map(&:to_i)

ans = 2018
zero_divided = false

l.upto(r - 1) do |i|
  if zero_divided
    ans = 0
    break
  end

  (i + 1).upto(r) do |j|
    p = i * j % 2019

    if p == 0
      zero_divided = true
      break
    end

    ans = p if p <= ans
  end
end

puts ans
//  [ruby]
L,R = gets.split.map &:to_i
r = [R, L + 2019].min

min = 2019
L.upto(r-1) do |i|
  (i+1).upto(r) do |j|
    a = (i*j)%2019
    if a == 0
      puts 0
      exit
    end
    if a < min
      min = a 
    end
  end
end

puts min
//  [ruby]
l,r = gets.split.map(&:to_i)
min = 2019
(l...r).each do |i|
    (i + 1..r).each do |j|
      mod = (i*j) % 2019
      if mod == 0
        p 0
        exit
      elsif mod < min
        min = mod
      end
    end
end
puts min
//  [ruby]
left, right = gets.chomp.split.map(&:to_i)

if right - left >= 2019 then
    puts 0
else
    res = 114514
    (left..right).each do |i|
        tmp = i % 2019
        res = tmp if tmp < res
    end
    puts res * (res+1)
end
//  [ruby]
x,y=gets.split.map &:to_i
sum=[]
mai=[]
if (x-y).abs>=4038
  puts 0
else
  for i in x..y
    sum << [i%2019,2019-i%2019].min
    mai << i
  end
  ans=sum.zip(mai).sort
  puts (ans[0][1]*ans[1][1])%2019
end
//  [ruby]
x,y=gets.split.map &:to_i
sum=[]
mai=[]
if (x-y).abs>=4038
  puts 0
else
  for i in x..y
    sum << i%2019
    mai << i
  end
  ans=sum.zip(mai).sort
  puts (ans[0][1]*ans[1][1])%2019
end
//  [rust]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}
const NUM: usize = 2019; 
fn main() {
    let lr = read_vec::<usize>();
    let (l, r) = (lr[0], lr[1]);

    let mut ans = NUM;
    'outer: for i in l..r {
        for j in i+1..r+1 {
            ans = std::cmp::min(i * j % NUM, ans);
            if ans == 0 {
                break 'outer;
            }
        }
    }

    println!("{}", ans);
}
//  [rust]
use std::io;
use std::cmp;


fn main() {
    let (l, r) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ans: usize = std::usize::MAX;
    'outer: for i in l..r + 1 { for j in (i + 1)..r + 1 {
        ans = cmp::min(ans, (i * j) % 2019);
        if ans == 0 { break 'outer; }
    }}

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let l: usize = iter.next().unwrap().parse().unwrap();
    let r: usize = iter.next().unwrap().parse().unwrap();

    let mut ans = std::usize::MAX;
    for i in l..r + 1 {
        for j in i + 1..r + 1 {
            ans = std::cmp::min(ans, i % 2019 * j % 2019);
            if ans == 0 {
                break;
            }
        }
        if ans == 0 {
            break;
        }
    }
    println!("{}", ans);
}
//  [rust]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}
impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }
    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    pub fn next_char(&mut self) -> char {
        self.next()
    }
    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}
fn main() {
    let mut sc = Scanner::new();
    let l = sc.next_usize();
    let r = sc.next_usize();

    let mut min = U_INF;
    let mut max = 0;

    for i in l..=r {
        min = (min).min(i % 2019);
        max = (max).max(i % 2019);
    }

    let mut ans = U_INF;
    for i in min..=max {
        for j in min..=max {
            if i != j {
                ans = (ans).min((i * j) % 2019);
            }
        }
    }

    println!("{}", ans);
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        l: u32,
        r: u32,
    }

    if r - l >= 2019 || l % 2019 >= r % 2019 {
        println!("0");
    }else {
        let mut three_x = false;
        let mut three_2x = false;
        let mut sst_x = false;
        let mut sst_2x = false;
        for i in l..r + 1 {
            if i % 6 == 0 {
                three_2x = true;
            } else if i % 3 == 0 {
                three_x = true;
            } else if i % 1346 == 0 {
                sst_2x = true;
            } else if i % 673 == 0 {
                sst_x = true;
            }
            if (three_x && sst_x) || (three_2x && sst_2x) {
                println!("0");
                return;
            }
        }
        println!("{}", ((l % 2019) * ((l + 1) % 2019)) % 2019);
    }
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        l: u32,
        r: u32,
    }

    if r - l >= 2019 || l % 2019 >= r % 2019 {
        println!("0");
    }else {
        let mut three_x = false;
        let mut sst_x = false;
        for i in l..r + 1 {
            if i % 3 == 0 {
                three_x = true;
            } else if i % 673 == 0 {
                sst_x = true;
            }
            if three_x && sst_x {
                println!("0");
                return;
            }
        }
        println!("{}", ((l % 2019) * ((l + 1) % 2019)) % 2019);
    }
}
//  [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 gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, 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) {
        _ = index(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() {
    let lr = readInts()
    let(l, r) = (lr[0], lr[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    if abs(l - r) >= 2019 {
        print(0)
        return
    }
    
    var ans = 2018
    for left in l..<r {
        for right in left + 1...r {
            if left >= right {
                break
            }
            ans = min(left * right % 2019, ans)
        }
    }
    print(ans)
}
main()
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (L, R) = (input[0], input[1])
var ans = 2019
loop: for i in L..<R {
  for j in i+1...R {
    ans = min((i*j)%2019, ans)
    if ans == 0 {
      break loop
    }
  }
}
print(ans)
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (L, R) = *readInt()
    if ((R-L) >= 2019) {
        print(0)
    } else {
        var mins = 2019
        for i in L..<R {
            for j in (i+1)...R {
                mins = min(mins, (i * j) % 2019)
            }
        }
        print(mins)
    }
}
main()
//  [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 gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, 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) {
        _ = index(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() {
    let lr = readInts()
    let(l, _) = (lr[0], lr[1])
    
    print((l + 1) * l % 2019)
}
main()
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//
 
import Foundation
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}
 
 
func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}
 
extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}
 
func main() {
    let (L, R) = *readInt()
    
    var mins = 2019
    for i in L..<R {
      for j in (i+1)...R {
        mins = min(mins, (i * j) % 2019)
      }
    }
    print(mins)
}
main()
//  [swift]
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (L, R) = *readInt()
    if ((R-L) >= 2019) {
        print(0)
    } else {
        var mins = 20000
        for i in L..<R {
            for j in (i+1)...R {
                mins = min(mins, (i * j) % 2019)
            }
        }
    }
}
main()
//  [typescript]
export class Main {
  static main(input): string {
    const [l, r]: number[] = input.split("\n")[0].split(" ").map(a => parseInt(a));
    const range = [];
    if (r - l >= 2019) {
      return "0";
    } else {
      for (let i = l; i <= r; i++) {
        range.push(i % 2019);
      }
    }
    let min = Infinity;
    for (let i = 0, len = range.length; i < len - 1; ++i) {
      for (let j = i + 1; j < len; ++j) {
        const p: number = (range[i] * range[j]) % 2019;
        if (p < min) {
          min = p;
        }
      }
    }
    return `${min}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
'use strict'
const main = (input: string) => {
    // 解説読みました
    const [l, r] = input.trim().split(' ').map(Number)
    const lmod = l % 2019
    const rmod = r % 2019
    if (r - l >= 2018) return console.log(0)
    let result = Infinity
    for (let i = lmod; i < rmod; i++) {
        for (let j = i+1; j <= rmod; j++) {
            result = Math.min(result, (i*j) % 2019)
        }
    }
    console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
const stdin = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .trim()

const [l, r] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  if (r - l >= 2019) {
    return 0
  } else {
    let min = Infinity
    for (let i = l; i < r; i++) {
      for (let j = i + 1; j <= r; j++) {
        if (i !== j) {
          const mod = ((i % 2019) * (j % 2019)) % 2019

          min = Math.min(min, mod)
        }
      }
    }

    return min
  }
}

console.log(ans())
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [l,r]=tnn(2),n=2019
  if(r-l>=2019){
    to(0)
    return
  }
  l=l%n
  r=r%n
  if(r<=l){
    to(0)
    return
  }
  to(r*(r+1)%n)
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [l,r]=tnn(2),n=2019
  let m=l%n,m_i=l
  if(r-l>=2019){
    to(0)
    return
  }
  for(let i=l;i<=r;i++){
    if(m>i%n){
      m=i%n
      m_i=i
      if(m==0){to(0);return}
    }
  }
  l=m_i
  r=l+1
  to((l%n)*(r%n)%n)
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [l,r]=tnn(2),n=2019
  let m=l%n,m_i=l
  for(let i=r;i>=l;i--){
    if(m>i%n){
      m=i%n
      m_i=i
      if(m==0)break
    }
  }
  l=m_i
  r=l+1
  to((l%n)*(r%n)%n)
}
main()
//  [python]
# tenka1-2019-beginnerC - Stones
def main():
    N, S = open(0).read().split()
    ans, blk = 0, 0
    for i in S:
        if i == "#":
            blk += 1
        else:
            if blk:
                ans += 1
                blk -= 1
    print(ans)


if __name__ == "__main__":
    main()
//  [python]
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    n = II()
    s = IS()
    cnt_b = 0
    cnt_w = s.count('.')
    cnt = cnt_w
    for si in s:
        if si == '#':
            cnt_b += 1
        else:
            cnt_w -= 1
        c = cnt_b+cnt_w
        if c < cnt:
            cnt = c
    print(cnt)

if __name__ == '__main__':
    main()
//  [python]
def C(N, S):
    n_diff_chars = S.count(".")
    cand_list = [n_diff_chars]
    for c in S:
        if c == ".":
            n_diff_chars -= 1
        else:
            n_diff_chars += 1
        cand_list.append(n_diff_chars)
    print(min(cand_list))


if __name__ == "__main__":
    N = int(input())
    S = input()
    C(N, S)
//  [python]
N = int(input())
stones = input()

w_cnt = stones.count('.')
b_cnt = N-w_cnt
first_bi = max(0, stones.find('#'))
last_wi = max(0, stones.rfind('.'))
pw_cnt = stones[first_bi:].count('.')
pb_cnt = stones[:last_wi].count('#')

print(min(w_cnt, b_cnt, pw_cnt, pb_cnt))
//  [python]
n = int(input())
s = input()
ans = 0
init = True
for i in range(n):
    if (not init) and s[i] == '#':
        ans -= 1
    if init and s[i] == '#':
        ans = n - i - 1
        init = False
cnt = 0
for c in s[::-1]:
    if c == '.':
        break
    cnt += 1
ans = min(ans, s.count('#') - cnt)
print(ans)
//  [python]
n = int(input())
s = input()
ans = 0
init = True
for i in range(n):
    if (not init) and s[i] == '#':
        ans -= 1
    if init and s[i] == '#':
        ans = n - i - 1
        init = False
print(ans)
//  [cpp]
#include<stdio.h>

int main(){
int n,i,ans=0,juge=0;
  
 scanf("%d",&n);
  
 char s[n];
  
 scanf("%s",s);
  
 for(i=0;i<n;i++){
    	if(s[i]=='.') {
          ans++;
        }
    }
 juge=ans;
 for(i=0;i<n;i++){
    	if(s[i]=='#') {juge++;}
      	else {juge--;}
      	if(juge<ans) {ans=juge;}
    }
  printf("%d",ans);
	return 0;
}
//  [cpp]
#include <stdio.h>
#include <algorithm>

const int N = 200005;

char a[N];

int main() {
  int n;
  scanf("%d %s", &n, a);
  int w = 0;
  for (int i = 0; i < n; i++) {
    w += (a[i] == '.');
  }
  int b = 0;
  int ans = (1 << 30);
  for (int i = 0; i < n; i++) {
    ans = std::min(ans, b + w);
    if (a[i] == '#') {
      b++;
    }
    if (a[i] == '.') {
      w--;
    }
  }
  printf("%d\n", std::min(ans, b + w));
  return 0;
}
//  [cpp]
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
   vector<int> b(n + 1);
   vector<int> w(n + 1);
   for(int i = 1;i <= n;i++){
         if(s[i - 1] == '#')b[i]++;
         else w[i]++;
         b[i] += b[i - 1];
         w[i] += w[i - 1];
   }
   int ans = n;
   for(int i = 0;i <= n;i++){
         ans = min(ans,i - b[i] + w[n] - w[i]);
   }
   cout << ans << endl;
}
//  [cpp]
#include <iostream>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int wht = 0;
    for(int i = 0;i < n;i++){
          if(s[i] == '.')wht++;
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
          if(i < wht){
                if(s[i] != '.')ans++;
          }else{
                if(s[i] != '#')ans++;
          }
    }
    cout << ans << endl;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N;

int solve(string S, string T) {
    int res = 0;
    rep(i, N - 1) {
        if (S[i] == T[0] && S[i + 1] == T[1]) {
            S[i + 1] = T[0];
            ++res;
        }
    }
    return res;
}

int main() {
    cin >> N;
    string S;
    cin >> S;

    string rS = S;
    reverse(rS.begin(), rS.end());
    cout << min(solve(S, "#."), solve(rS, ".#")) << endl;
}
//  [c]
#include<stdio.h>
int main(){
  int N,cnt=0,i,min;
  scanf("%d",&N);
  char S[N+1];
  scanf("%s",S);
  
  for(i=0;i<N;i++){
    if(S[i]=='.')cnt++;
  }
  if(S[0]=='.'){
    cnt--; 
    min=cnt;
  }
  else {
    min=cnt; 
    cnt++;
  }

  for(i=1;i<N;i++){
    if(S[i]=='.')cnt--;
    else cnt++;
    if(cnt<min){
      min=cnt;
    }
  }
  printf("%d\n",min);

  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void) {
	int n,w = 0,b = 0;
	scanf("%d", &n);
	char s[n + 1];
	scanf("%s", s);
	for (int i = 0;i < n;i++) {
		if (s[i] == '.') {
			w++;
		}
	}
	if (w == 0 || w == n) {
		printf("0");
		return 0;
	}
	int ans = w;
	for (int i = 0;i < n;i++) {
		if (s[i] == '.') {
			w--;
		}
		else {
			b++;
		}
		if (ans > w + b) {
			ans = w + b;
		}
	}
	printf("%d", ans);
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i=0,N,min,cnt=0;
  char ss[200001];
  scanf("%d",&N);
  scanf("%s",ss);
  while(i<N){
    if(ss[i]=='.'){
      cnt++;
    }
    i++;
  }
  if(ss[0]=='.')cnt--;
  min=cnt;
  for(i=1;i<N;i++){
    if(ss[i]=='.')cnt--;
    if(ss[i-1]=='#')cnt++;
    if(min>cnt)min=cnt;
  }
  printf("%d\n",min);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,tmp2=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  scanf("%s",s);
  result=1<<29;
  rep(i,n){
    tmp2+=((s[i]=='.') ? 1 : 0);
  }
  rep(i,n){
    tmp +=((s[i]=='#') ? 1 : 0);
    tmp2-=((s[i]=='.') ? 1 : 0);
    result=min(result,tmp+tmp2);
  }
  printf("%lld",result);
  
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    char s[200005];  
    ll n,ans=0;
    scanf("%lld%s",&n,s);
    ll bw[n],black;
    bw[n-1]=0;
    rrep(i,n-2,0){
        bw[i]=bw[i+1];
        if(s[i+1]=='#') bw[i]++;
    }
    // rep(i,0,n) printf("%lld ",bw[i]);
    black=bw[0];
    if(s[0]=='#') black++;

    if(s[0]=='#'){
        ans=(n-1)-bw[0];
    }else{
        ans=(n-1)-(bw[0]+1);
    }
    rep(i,1,n){
        // ans=min2(ans, (black-b[]) )
        if(s[i]=='.'){
            ans=min2(ans, (black-bw[i])+1+(n-1-i)-bw[i] );
        }else{
            ans=min2(ans, (black-bw[i]-1)+(n-1-i)-bw[i] );
        }
    }
    ans=min2(ans,black);
    printf("%lld\n",ans);
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    char s[200005];  
    ll n,ans=0;
    scanf("%lld%s",&n,s);
    ll bw[n],black;
    bw[n-1]=0;
    rrep(i,n-2,0){
        bw[i]=bw[i+1];
        if(s[i+1]=='#') bw[i]++;
    }
    // rep(i,0,n) printf("%lld ",bw[i]);
    black=bw[0];
    if(s[0]=='#') black++;

    if(s[0]=='#'){
        ans=(n-1)-bw[0];
    }else{
        ans=(n-1)-(bw[0]+1);
    }
    rep(i,1,n){
        // ans=min2(ans, (black-b[]) )
        if(s[i]=='.'){
            ans=min2(ans, (black-bw[i])+1+(n-1-i)-bw[i] );
        }else{
            ans=min2(ans, (black-bw[i])+(n-1-i)-bw[i] );
        }
    }
    ans=min2(ans,black);
    printf("%lld\n",ans);
    return 0;
}
//  [javascript]
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=r[1].split(""),o=0,u=0;u<t;u++){"."==n[u]&&(o+=1)}for(var i=o,f=0,l=9999999,c=0;c<t;c++){var a=n[c];"."==a&&(i-=1);var p=f+i;p<l&&(l=p),"#"==a&&(f+=1)}console.log(l)}},function(e,r){e.exports=require("fs")}]);
//  [javascript]

function Main(input) {
  // 数字
  var N = parseInt(input[0], 10);
  var S = input[1];

  // 0番目から探索するためrightWには全ての白を初期値として入れる
  var leftB = 0;
  var rightW = S.split('.').length - 1;

  var result = rightW;
  
  for (var i = 0; i < S.length; i++) {
    if (S.charAt(i) === '.') {
      rightW--;
    } else {
      leftB++;
    }
    result = (rightW + leftB) < result ? (rightW + leftB) : result;
  }

  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));
//  [javascript]
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var A = intShift();
  var B = strShift();
  
  var s = 0;
  
  for(var i = 0; i < A; i++){
  	if(B[i] == ".")s++;
  }
  var min = s;
  for(var i = 0; i < A; i++){
  	if(B[i] == "."){
    	s--;
    }else{
    	s++;
    }
    min = Math.min(min,s);
  }
  
  return ~~min;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5
#.##.
`);