package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	cntOp := 0
	length := 0

	s := make([]uint8, n+2)
	s[0] = 'a'
	s[n+1] = 'a'
	scanner.Split(bufio.ScanBytes)
	next()
	for i := 0; i < n; i++ {
		c := next()

		if c != "." {
			if length > 1 {
				cntOp += length - 1
			}
			length = 0
		} else {
			length++
		}
		// println(length, cntOp)
		s[i+1] = uint8(c[0])
	}

	if length > 1 {
		cntOp += length - 1
	}

	// println(cntOp, string(s), s)
	scanner.Split(bufio.ScanWords)
	for ; m > 0; m-- {
		// println(next())
		pos, c := nextInt(), uint8(next()[0])
		// println(pos, string(c), c)

		if (s[pos] == '.' && c == '.') || (isAlpha(s[pos]) && isAlpha(c)) {
			println(cntOp)
			continue
		}

		s[pos] = c
		if s[pos-1] == '.' && s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 2
			} else {
				cntOp -= 2
			}
		} else if s[pos-1] == '.' || s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 1
			} else {
				cntOp -= 1
			}
		}
		// println(string(s))
		println(cntOp)
	}
}

func isAlpha(c uint8) bool {
	if c >= 'a' && c <= 'z' {
		return true
	}

	return false
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

    package main
    import(
        "fmt"
        "bufio"
        "os"
        "strconv"
        "strings"
        // "reflect"
    )

    type Input struct{
        scanner *bufio.Scanner
        isWord bool
    }

    func (int *Input) init(){
        if in.scanner == nil {
            in.scanner = bufio.NewScanner(os.Stdin)
            in.isWord = false
        }
    }

    func (in *Input) scanInt() int{
        in.init()
        in.scanner.Scan()
        var i int
        i,_ = strconv.Atoi(in.scanner.Text())
        return i
    }

    func (in *Input) scanStrByte(length int) string{

        in.isWord = false
        in.init();
        in.scanner.Split(bufio.ScanBytes)

        s := make([]byte, length+2)

        for i := 0; i < length; i++{
            in.scanner.Scan();
            s[i] = in.scanner.Text()[0]
        }

        return string(s)

    }

    func (in *Input) scanStr() string{
        in.init()
        if !in.isWord{
                in.scanner.Split(bufio.ScanWords)
                in.isWord = true
        }

        in.scanner.Scan()
        return in.scanner.Text()
    }

    func (in *Input) scanIntArray() []int{
        in.init()
        strArray := strings.Split(in.scanStr(), " ");
        length := len(strArray)

        var intArray []int
        for i := 0; i < length; i++ {
            v,_ := strconv.Atoi(strArray[i])
            intArray = append(intArray, v)
        }

        return intArray
    }

    var in Input

    var ar[300005] int
    func main(){

        var inputAr [2]int
        inputAr[0],_ = strconv.Atoi(in.scanStr())
        // inputAr[0] = x
        inputAr[1],_ = strconv.Atoi(in.scanStr())
        in.scanStrByte(1)

        str := in.scanStrByte(inputAr[0])

        strLen := inputAr[0]

        totDot := 0
        totSeg := 0

        dot := "."
        // if(strLen > 1000){
        //     fmt.Println("Hello")
        //     fmt.Println(reflect.ValueOf(str).Kind())
        //     fmt.Println(str)
        //     return
        // }

        for i := 0; i < strLen; i++{
            if str[i] == dot[0]{
                ar[i+1] = 1
                totDot++

                if i == 0 {
                    totSeg++
                } else if str[i-1] != dot[0] {
                    totSeg++
                }

            } else {
                ar[i+1] = 0
            }
        }

        // writer  := bufio.NewWriter(os.Stdout)
        // defer writer.Flush()

        // fmt.Println(str)
        for i := 0; i < inputAr[1]; i++{

            var mStr [2]string
            mStr[0] = in.scanStr()
            mStr[1] = in.scanStr()
            // fmt.Println(mStr)

            // mStr := strings.Split(in.scanStr(), " ")
            // fmt.Println(mStr)
            ind,_ := strconv.Atoi(mStr[0])
            if mStr[1][0] == dot[0]{
                if(ar[ind] != 1){
                    totDot++
                    ar[ind] = 1
                    //decrease segment
                    if ar[ind-1] == 1 && ar[ind+1] == 1{
                        totSeg--
                    } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                            totSeg++
                    }

                }
            } else{
                if ar[ind] == 1{
                    totDot--
                    ar[ind] = 0

                    if ar[ind-1] == 1 && ar[ind+1] == 1{
                        totSeg++
                    } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                            totSeg--
                    }
                }
            }

            fmt.Println((totDot - totSeg))
            // fmt.Fprintln(writer, (totDot - totSeg))
        }

    }

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/570/C

package main

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

type Query struct {
	Position int
	Letter   string
}

func getAdjacent(arr []string, index int, n int) int {
	count := 0
	if index-1 >= 0 && arr[index-1] == "." {
		count += 1
	}
	if index+1 < n && arr[index+1] == "." {
		count += 1
	}
	return count
}

func Solve(n int, m int, s string, queries []Query) []int {
	arr := strings.Split(s, "")
	replacements := 0
	for i := 0; i < n-1; i++ {
		if arr[i] == "." && arr[i+1] == "." {
			replacements += 1
		}
	}
	answers := make([]int, m)
	for i, query := range queries {
		adjCount := getAdjacent(arr, query.Position-1, n)
		if arr[query.Position-1] == "." && query.Letter != "." {
			replacements -= adjCount
		}
		if arr[query.Position-1] != "." && query.Letter == "." {
			replacements += adjCount
		}
		arr[query.Position-1] = query.Letter
		answers[i] = replacements
	}
	return answers
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	queries := make([]Query, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d %s\n", &queries[i].Position, &queries[i].Letter)
	}

	answers := Solve(n, m, s, queries)
	for _, elem := range answers {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

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

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  line, _ := reader.ReadString('\n')
  var n, q int
  fmt.Sscanf(line, "%d %d", &n, &q)
  line, _ = reader.ReadString('\n')
  s := make([]byte, n + 2)
  periods, spans := 0, 0
  for i := 1; i <= n; i++ {
    ch := line[i - 1]
    s[i] = ch
    if ch == '.' {
      periods++
      if s[i - 1] != '.' {
        spans++
      }
    }
  }
  for i := 0; i < q; i++ {
    line, _ = reader.ReadString('\n')
    var pos int
    var ch byte
    fmt.Sscanf(line, "%d %c", &pos, &ch)
    left, right := s[pos - 1], s[pos + 1]
    if s[pos] == '.' {
      if ch != '.' {
        periods--
        if left != '.' && right != '.' {
          spans--
        }
        if left == '.' && right == '.' {
          spans++
        }
      }
    } else {
      if ch == '.' {
        periods++
        if left != '.' && right != '.' {
          spans++
        }
        if left == '.' && right == '.' {
          spans--
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", periods - spans))
    s[pos] = ch
  }
}

package main

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

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  line, _ := reader.ReadString('\n')
  var n, q int
  fmt.Sscanf(line, "%d %d", &n, &q)
  line, _ = reader.ReadString('\n')
  s := make([]byte, n + 2)
  periods, spans := 0, 0
  for i := 1; i <= n; i++ {
    ch := line[i - 1]
    s[i] = ch
    if ch == '.' {
      periods++
      if s[i - 1] != '.' {
        spans++
      }
    }
  }
  for i := 0; i < q; i++ {
    line, _ = reader.ReadString('\n')
    var ch byte
    var pos int
    fmt.Sscanf(line, "%d %c", &pos, &ch)
    left, right := s[pos - 1], s[pos + 1]
    if s[pos] == '.' {
      if ch != '.' {
        periods--
        if left != '.' && right != '.' {
          spans--
        }
        if left == '.' && right == '.' {
          spans++
        }
      }
    } else {
      if ch == '.' {
        periods++
        if left != '.' && right != '.' {
          spans++
        }
        if left == '.' && right == '.' {
          spans--
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", periods - spans))
    s[pos] = ch
  }
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF570C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, q, p, dot, seg int
	var s, c []byte
	Fscan(in, &n, &q, &s)
	for i, b := range s {
		if b == '.' {
			dot++
			if i == 0 || s[i-1] != '.' {
				seg++
			}
		}
	}
	s = append([]byte{0}, append(s, 0)...)
	for ; q > 0; q-- {
		Fscan(in, &p, &c)
		if s[p] == '.' != (c[0] == '.') {
			d := -1
			if c[0] == '.' {
				d = 1
			}
			dot += d
			if s[p-1] != '.' && s[p+1] != '.' {
				seg += d
			} else if s[p-1] == '.' && s[p+1] == '.' {
				seg -= d
			}
			s[p] = c[0]
		}
		Fprintln(out, dot-seg)
	}
}

func main() { CF570C(os.Stdin, os.Stdout) }

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	cntOp := 0
	length := 0

	s := make([]uint8, n+2)
	s[0] = 'a'
	s[n+1] = 'a'
	scanner.Split(bufio.ScanBytes)
	next()
	for i := 0; i < n; i++ {
		c := next()

		if c != "." {
			if length > 1 {
				cntOp += length - 1
			}
			length = 0
		} else {
			length++
		}
		// println(length, cntOp)
		s[i+1] = uint8(c[0])
	}

	if length > 1 {
		cntOp += length - 1
	}

	scanner.Split(bufio.ScanWords)
	// println(cntOp, string(s), s)
	for ; m > 0; m-- {
		// println(next())
		pos, c := nextInt(), uint8(next()[0])
		s[pos] = c
		// println(pos, string(c), c)
		if s[pos-1] == '.' && s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 2
			} else {
				cntOp -= 2
			}
		} else if s[pos-1] == '.' || s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 1
			} else {
				cntOp -= 1
			}
		}
		// println(string(s))
		println(cntOp)
	}
}

func isAlpha(c uint8) bool {
	if c >= 'a' && c <= 'z' {
		return true
	}

	return false
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    // writer  := bufio.NewWriter(os.Stdout)
    // defer writer.Flush()

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println((totDot - totSeg))
        // fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    // in.init()
    //
    // rd := bufio.NewReader(os.Stdin);
    // bt := make([]byte, 500000);
    // rd.Read(bt)
    // return string(bt)

    var str string
    fmt.Scan(&str)
    return str

    //in.scanner.Scan()
    //return in.scanner.Text()
}

func (in *Input) scanStr2() string{
    // in.init()
    // in.scanner.Scan()
    // return in.scanner.Text()
    var str string
    fmt.Scan(&str)
    return str
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr2(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    // fmt.Println(in.scanStr())
    // rd := bufio.NewReader(os.Stdin)
    // // rd.ReadLine()
    // line, hasMoreLine, err := rd.ReadLine()
    // rd.ReadLine()
    // fmt.Println(line, hasMoreLine, err)
    // fmt.Println(string(bt))
    // var test string
    // fmt.Scanln(&test)
    // fmt.Println(test)

    // inputAr := in.scanIntArray()
    // str := in.scanStr()
    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStr()

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(reflect.ValueOf(str).Kind())
        fmt.Println(str)
        return
    }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        var mStr [2]string
        fmt.Scan(&mStr[0])
        fmt.Scan(&mStr[1])

        // mStr := strings.Split(in.scanStr2(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0
    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }
    dot := "."
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    inputAr[0],_ = strconv.Atoi(in.scanStr())
    // inputAr[0] = x
    inputAr[1],_ = strconv.Atoi(in.scanStr())

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    // writer  := bufio.NewWriter(os.Stdout)
    // defer writer.Flush()

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println((totDot - totSeg))
        // fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello", str)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // t := &Input{}
    // fmt.Println(reflect.ValueOf(t).Kind())

    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(reflect.ValueOf(str).Kind())
        fmt.Println(str)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello", strLen)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    writer  := bufio.NewWriter(os.Stdout)
    defer writer.Flush()

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(len(str))
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _, _ := reader.ReadLine()

	val := strings.Split(string(text), " ")
	var val2 [4]int64

	var res []string

	val2[0], _ = strconv.ParseInt(val[0], 10, 0)
	val2[1], _ = strconv.ParseInt(val[1], 10, 0)
	val2[2], _ = strconv.ParseInt(val[2], 10, 0)
	val2[3], _ = strconv.ParseInt(val[3], 10, 0)
	//res = append(res, 0)
	i := int(val2[2])
	j := int(val2[3])
	ii := int(val2[0])
	jj := int(val2[1])

	for ; i <= ii; i++ {
		for j = int(val2[3]); j <= jj; j++ {
			if i > j {
				res = append(res, strconv.Itoa(i)+" "+strconv.Itoa(j))
			}

		}

	}

	fmt.Println(len(res))
	for k := 0; k < len(res); k++ {
		fmt.Println(res[k])
	}

}

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

func main() {
	var x,y,a,b int
	n:=0
	out := bufio.NewWriter(os.Stdout)

	fmt.Scan(&x,&y,&a,&b)
	for i:=a;i<=x;i++{
		for j:=b;j<=y;j++ {
			if i>j {
				n++
			}
		}
	}
	fmt.Println(n)
	for i:=a;i<=x;i++{
		for j:=b;j<=y;j++ {
			if i>j {
				//fmt.Println(i,j)
				out.WriteString(strconv.Itoa(i))
				//fmt.Println()
				out.Flush()
				fmt.Print(" ")
				out.WriteString(strconv.Itoa(j))
				out.Flush()
				fmt.Println()
			}
		}
	}
	out.Flush()
}

package main

import "fmt"

type Outcome struct {
    p,q int
}

func main() {
    var x,y,a,b int
    var ans [10000]Outcome
    fmt.Scan(&x,&y,&a,&b)
    cnt := 0
    for i := a; i <= x; i++ {
        for j := b; (j <= y) && (j < i); j++ {
            ans[cnt].p = i
            ans[cnt].q = j
            cnt++
        }
    }
    fmt.Println(cnt)
    for i := 0; i < cnt; i++ {
        fmt.Println(ans[i].p,ans[i].q)
    }
}

package main

import "fmt"

type Outcome struct {										// membuat fungsi struct
    p,q int												    // variabel p dan q dengan jenis int
}

func main() {
    var x,y,a,b int										// variabel x,y,a,b berjenis int
    var ans [10000]Outcome								// var ans [10000]berjenis struct Outcome
    fmt.Scan(&x,&y,&a,&b)								// mengambil input
    cnt := 0											// membuar variabel cnt dan diisi nilai 0
    for i := a; i <= x; i++ {							// looping
        for j := b; (j <= y) && (j < i); j++ {			// looping ke 2
            ans[cnt].p = i								// ans[cnt].p sama dengan i
            ans[cnt].q = j								// ans[cnt].q  sama dengan j
            cnt++										// cnt ditambah terus
        }
    }
    fmt.Println(cnt)								   // cetak hasil cnt
    for i := 0; i < cnt; i++ {							// looping ke 3
        fmt.Println(ans[i].p,ans[i].q)					// cetak hasil ans[i].p dan ans[i].q
    }
}

package main

import "fmt"

type pair struct{
	first, second int
}

func main() {
	var x, y, a, b int
	var pairs []pair
	fmt.Scanf("%d %d %d %d\n", &x, &y, &a, &b)
	for i := a ; i <= x; i++ {
		for j := b; j <= y; j++ {
			if i > j {
				pairs = append(pairs, pair{first: i, second: j})
			}
		}
	}

	fmt.Println(len(pairs))
	for _, p := range pairs {
		fmt.Println(p.first, p.second)
	}
}

// 242A-mic
package main

import (
    "fmt"
)

func main() {
    var x, y, a, b, o int
    fmt.Scan(&x, &y, &a, &b)
    if b > a {
        a = b + 1
    }

    for i := a; i <= x; i++ {
        for j := b; j < i; j++ {
            if j > y {
                break
            }
            o++
        }
    }
    fmt.Print(o)
    for i := a; i <= x; i++ {
        for j := b; j < i; j++ {
            if j > y {
                break
            }
            fmt.Println()
            fmt.Print(i)
            fmt.Print(" ")
            fmt.Print(j)
        }
    }
}