object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[(Char,Char)]()
  var setT = Set[(Char,Char)]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0

  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS.map(x => x._1) contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT.map(x => x._1) contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setT contains Tuple2(s(i),t(i))) && (setS contains Tuple2(t(i),s(i))) && (flag != 2))
        {idxS = i; idxT = i; flag = 2}
      }

      setS += Tuple2(s(i),t(i))
      setT += Tuple2(t(i),s(i))
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && (idxS != i))
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && (idxT != i))
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if((s(i) == chr2) && (t(i) == chr1) && (idxT != i))
          idxS = i
      }

      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

import java.io._
import java.util
import java.util._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val n = nextInt
    val s = next.toCharArray
    val t = next.toCharArray
    var curr = 0
    val a = new Array[Array[Int]](27)
    for (i <- 0 until 27) {
      a(i) = new Array[Int](27)
    }
    for (i <- 0 until n) {
      if (s(i) != t(i)) {
        curr += 1
        a(s(i) - 'a')(t(i) - 'a') = i + 1
      }
    }
    for (i <- 0 until a.length) {
      for (j <- i + 1 until a(i).length) {
        if (a(i)(j) >= 1 && a(j)(i) >= 1) {
          out.println(curr - 2)
          out.println(a(i)(j) + " " + a(j)(i))
          return 1
        }
      }
    }

    for (i <- 0 until a.length) {
      var a1 = 0
      var a2 = 0
      for (j <- 0 until a(i).length) {
        a1 = Math.max(a1, a(i)(j))
        a2 = Math.max(a2, a(j)(i))
      }
      if (a1 >= 1 && a2 >= 1) {
        out.println(curr - 1)
        out.println(a1 + " " + a2)
        return 1
      }
    }
    out.println(curr)
    out.println("-1 -1")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

/**
 * Created by ronaflx on 15-4-3.
 */
object Codeforces {
  def evalRecord(x: Int): Int = { if (x > 0) 1 else 0 }

  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val a = io.StdIn.readLine()
    val b = io.StdIn.readLine()
    var record = Array.ofDim[Int](26, 26)
    var hamming: Int = 0
    for (i <- 0 to n - 1) {
      if (a.charAt(i) != b.charAt(i)) {
        record(a.charAt(i).toInt - 97)(b.charAt(i).toInt - 97) = i + 1
        hamming += 1
      }

    }
    var delta: Int = 0
    var posa = -1
    var posb = -1
    for (i <- 0 to 25; j <- 0 to 25) {
      if (i != j) {
        if (delta < evalRecord(record(i)(j)) + evalRecord(record(j)(i)) && record(i)(j) != 0 && record(j)(i) != 0) {
          delta = 2
          posa = record(i)(j)
          posb = record(j)(i)
        }
        for (k <- 0 to 25) {
          if (delta < evalRecord(record(i)(j)) && j != k && record(j)(k) != 0) {
            delta = 1
            posa = record(i)(j)
            posb = record(j)(k)
          }
        }
      }
    }
    println(hamming - delta)
    println(posa + " " + posb)
  }
}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && flag != 2)
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && idxS != i)
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && idxT != i)
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if((s(i) == chr2) && (t(i) == chr1) && idxT != i)
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && (flag != 2))
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && (idxS != i))
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && (idxT != i))
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if((s(i) == chr2) && (t(i) == chr1) && (idxT != i))
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
if(idxS == idxT)
print("FUCK")
    }
  }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && flag != 2)
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && idxS != i)
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && idxT != i)
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if(s(i) == chr2 && t(i) == chr1)
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && flag != 2)
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

 flag
  match
 {
   case 0 => {println(res); println("-1 -1")}
   case 1 => {
     println(res - 1)
     if(idxS > 0)
     {
       for(i <- 0 until n)
       {
         if((s(i) != t(i)) && (t(i) == s(idxS)))
           idxT = i
       }
       idxS += 1
       idxT += 1
       println(idxS + " " + idxT)
     }
     else {
       for(i <- 0 until n)
       {
         if((s(i) != t(i)) && (s(i) == t(idxT)))
           idxS = i
       }
       idxS += 1
       idxT += 1
       println(idxT + " " + idxS)
     }
   }
   case 2 =>
   {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
     for(i <- 0 until n)
     {
       if(s(i) == chr2 && t(i) == chr1)
         idxS = i
     }
     println(res - 2)
     idxS += 1
     idxT += 1
     println(idxS + " " + idxT)
   }
 }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && (flag != 2))
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS >= 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && (idxS != i))
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && (idxT != i))
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if((s(i) == chr2) && (t(i) == chr1) && (idxT != i))
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        else
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && flag != 2)
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)))
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)))
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if(s(i) == chr2 && t(i) == chr1)
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

object B524 extends App{

  import scala.collection.mutable.Queue

  val n = readInt
  val s = readLine
  val t = readLine
  var q = List[(Char, Char, Int)]()
  var setS = Set[Char]()
  var setT = Set[Char]()
  var idxS = -1
  var idxT = -1
  var flag = 0
  var res = 0
  for(i <- 0 until n)
  {
    if(s(i) != t(i))
    {
      if(flag == 0) {
        if (setS contains t(i)) {
          idxT = i
          flag += 1
        }
        if (setT contains s(i)) {
          idxS = i
          flag += 1
        }
      }
      else
      {
        if((setS contains t(i)) && (setT contains s(i)) && (flag != 2))
        {idxS = i; idxT = i; flag = 2}
      }

      setS += s(i)
      setT += t(i)
      res += 1
    }
  }

  flag
  match
  {
    case 0 => {println(res); println("-1 -1")}
    case 1 => {
      println(res - 1)
      if(idxS > 0)
      {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (t(i) == s(idxS)) && (idxS != i))
            idxT = i
        }
        idxS += 1
        idxT += 1
        println(idxS + " " + idxT)
      }
      else {
        for(i <- 0 until n)
        {
          if((s(i) != t(i)) && (s(i) == t(idxT)) && (idxT != i))
            idxS = i
        }
        idxS += 1
        idxT += 1
        println(idxT + " " + idxS)
      }
    }
    case 2 =>
    {
      val chr1 = s(idxS)
      val chr2 = t(idxT)
      for(i <- 0 until n)
      {
        if((s(i) == chr2) && (t(i) == chr1) && (idxT != i))
          idxS = i
      }
      println(res - 2)
      idxS += 1
      idxT += 1
      println(idxS + " " + idxT)
    }
  }

}

/**
 * Created by ronaflx on 15-4-3.
 */
object Codeforces {
  def evalRecord(x: Int): Int = { if (x > 0) 1 else 0 }

  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val a = io.StdIn.readLine()
    val b = io.StdIn.readLine()
    var record = Array.ofDim[Int](26, 26)
    for (i <- 0 to n - 1) {
      if (a.charAt(i) != b.charAt(i)) {
        record(a.charAt(i).toInt - 97)(b.charAt(i).toInt - 97) = i + 1
      }
    }
    var hamming: Int = 0
    var delta: Int = 0
    var posa = -1
    var posb = -1
    record.foreach(hamming += _.count(_ > 0))
    for (i <- 0 to 25; j <- 0 to 25) {
      if (i != j) {
        if (delta < evalRecord(record(i)(j)) + evalRecord(record(j)(i)) && record(i)(j) != 0 && record(j)(i) != 0) {
          delta = 2
          posa = record(i)(j)
          posb = record(j)(i)
        }
        for (k <- 0 to 25) {
          if (delta < evalRecord(record(i)(j)) && j != k && record(j)(k) != 0) {
            delta = 1
            posa = record(i)(j)
            posb = record(j)(k)
          }
        }
      }
    }
    println(hamming - delta)
    println(posa + " " + posb)
  }
}

import java.io._
import java.util
import java.util._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val n = nextInt
    val s = next.toCharArray
    val t = next.toCharArray
    var curr = 0
    val a = new Array[Array[Int]](27)
    for (i <- 0 until 27) {
      a(i) = new Array[Int](27)
    }
    for (i <- 0 until n) {
      if (s(i) != t(i)) {
        curr += 1
        a(s(i) - 'a')(t(i) - 'a') = i
      }
    }
    for (i <- 0 until a.length) {
      for (j <- i + 1 until a(i).length) {
        if (a(i)(j) >= 1 && a(j)(i) >= 1) {
          out.println(curr - 2)
          out.println((i + 1) + " " + (j + 1))
          return 1
        }
      }
    }

    for (i <- 0 until a.length) {
      var a1 = 0
      var a2 = 0
      for (j <- 0 until a(i).length) {
        a1 = Math.max(a1, a(i)(j))
        a2 = Math.max(a2, a(j)(i))
      }
      if (a1 >= 1 && a2 >= 1) {
        out.println(curr - 1)
        out.println((a1 + 1) + " " + (a2 + 1))
        return 1
      }
    }
    out.println(curr)
    out.println("-1 -1")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.io._
import java.util
import java.util._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val n = nextInt
    val s = next.toCharArray
    val t = next.toCharArray
    var curr = 0
    val t1 = new util.HashMap[Character, ArrayList[Int]]()
    val pos = new util.ArrayList[Int]()
    for (i <- 0 until n) {
      if (s(i) != t(i)) {
        pos.add(i)
        curr += 1
        if (!t1.containsKey(t(i))) {
          val list = new util.ArrayList[Int]()
          list.add(i)
          t1.put(t(i), list)
        } else {
          t1.get(t(i)).add(i)
        }
      }
    }
    var i1 = -1
    var i2 = -1
    var min = curr
    for (i <- 0 until pos.size()) {
      val s1: Char = s(pos.get(i))
      if (null != t1.get(s1)) {
        val ind = t1.get(s1)
        for (j <- 0 until ind.size()) {
          if (s(ind.get(j)) == t(i)) {
            if (curr - 2 < min) {
              min = curr - 2
              i1 = i
              i2 = ind.get(j)
              out.println(min)
              out.println((i1 + 1) + " " + (i2 + 1))
              return 1
            }
          } else {
            if (curr - 1 < min) {
              min = curr - 1
              i1 = i
              i2 = ind.get(j)
            }
          }
        }
      }
    }
    if (min == curr) {
      out.println(curr)
      out.println("-1 -1")
    } else {
      out.println(min)
      out.println((i1 + 1) + " " + (i2 + 1))
    }
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.io._
import java.util
import java.util._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val n = nextInt
    val s = next.toCharArray
    val t = next.toCharArray
    var curr = 0
    val a = new Array[Array[Int]](27)
    for (i <- 0 until 27) {
      a(i) = new Array[Int](27)
    }
    for (i <- 0 until n) {
      if (s(i) != t(i)) {
        curr += 1
        a(s(i) - 'a')(t(i) - 'a') = i + 1
      }
    }
    for (i <- 0 until a.length) {
      for (j <- i + 1 until a(i).length) {
        if (a(i)(j) >= 1 && a(j)(i) >= 1) {
          out.println(curr - 2)
          out.println(i + " " + j)
          return 1
        }
      }
    }

    for (i <- 0 until a.length) {
      var a1 = 0
      var a2 = 0
      for (j <- 0 until a(i).length) {
        a1 = Math.max(a1, a(i)(j))
        a2 = Math.max(a2, a(j)(i))
      }
      if (a1 >= 1 && a2 >= 1) {
        out.println(curr - 1)
        out.println(a1 + " " + a2)
        return 1
      }
    }
    out.println(curr)
    out.println("-1 -1")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.io._
import java.util
import java.util._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return java.lang.Long.parseLong(next)
  }

  def solve: Int = {
    val n = nextInt
    val s = next.toCharArray
    val t = next.toCharArray
    var curr = 0
    val t1 = new util.HashMap[Character, ArrayList[Int]]()
    val pos = new util.ArrayList[Int]()
    for (i <- 0 until n) {
      if (s(i) != t(i)) {
        pos.add(i)
        curr += 1
        if (!t1.containsKey(t(i))) {
          val list = new util.ArrayList[Int]()
          list.add(i)
          t1.put(t(i), list)
        } else {
          t1.get(t(i)).add(i)
        }
      }
    }
    var i1 = -1
    var i2 = -1
    var min = curr
    for (i <- 0 until pos.size()) {
      val s1: Char = s(pos.get(i))
      if (null != t1.get(s1)) {
        val ind = t1.get(s1)
        for (j <- 0 until ind.size()) {
          if (s(ind.get(j)) == t(i)) {
            if (curr - 2 < min) {
              min = curr - 2
              i1 = pos.get(i)
              i2 = ind.get(j)
              out.println(min)
              out.println((i1 + 1) + " " + (i2 + 1))
              return 1
            }
          } else {
            if (curr - 1 < min) {
              min = curr - 1
              i1 = pos.get(i)
              i2 = ind.get(j)
            }
          }
        }
      }
    }
    if (min == curr) {
      out.println(curr)
      out.println("-1 -1")
    } else {
      out.println(min)
      out.println((i1 + 1) + " " + (i2 + 1))
    }
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}


/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    // Write your solution here
    val t = readInt

    for (_ <- 0 until t) {
      val splitLine = readLine.split(" ").map(_.toLong)
      var a = splitLine(0)
      var b = splitLine(1)
      var x = splitLine(2)
      var y = splitLine(3)
      val n = splitLine(4)

      var ans = 1000000000000000000L

      for (_ <- 0 until 2) {
        val da = math.min(n, a - x)
        val db = math.min(n - da, b- y)
        ans = math.min(ans, (a - da) * (b - db))

        val tmpab = b
        b = a
        a = tmpab

        val tmpxy = y
        y = x
        x = tmpxy
      }

      println(ans)
    }
  }
}

//package codeforces.contests._1409

object MinimumProduct {
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {

      val Array(a, b, x, y, n) = io.StdIn.readLine.split(" ").map(_.toInt)

      val (f, s) = {
        val aD = (a - n) max x
        val bD = (b - n) max y

        if (aD <= bD) (aD, (b - (n - (a - aD))) max y)
        else ((a - (n - (b - bD))) max x, bD)
      }

      println(f.toLong * s.toLong)
    }
  }
}

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 */
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    // Write your solution here
    /*
    int t;
      cin >> t;
      while (t--) {
        int a, b, x, y, n;
        cin >> a >> b >> x >> y >> n;
        long long ans = 1e18;
        for (int i = 0; i < 2; ++i) {
          int da = min(n, a - x);
          int db = min(n - da, b - y);
          ans = min(ans, (a - da) * 1ll * (b - db));
          swap(a, b);
          swap(x, y);
        }
        cout << ans << endl;
      }

      return 0;
     */

    def swap(x: Long, y: Long) = {

    }
    val t = readInt

    for (_ <- 0 until t) {
      val splitLine = readLine.split(" ").map(_.toLong)
      var a = splitLine(0)
      var b = splitLine(1)
      var x = splitLine(2)
      var y = splitLine(3)
      val n = splitLine(4)

      var ans = 1000000000000000000L

      for (_ <- 0 until 2) {
        val da = math.min(n, a - x)
        val db = math.min(n - da, b- y)
        ans = math.min(ans, (a - da) * (b - db))

        val tmpab = b
        b = a
        a = tmpab

        val tmpxy = y
        y = x
        x = tmpxy
      }

      println(ans)
    }
  }
}

object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine.toInt
    for (_ <- 0 until t) {
      val arr = StdIn.readLine.split(" ").map(_.toLong)
      val (a,b,x,y,n) = (arr(0), arr(1), arr(2), arr(3), arr(4))

      def cal(a: Long, b: Long, x: Long, y: Long, n: Long) = {
        val sub = math.min(a - x, n)
        val sub2 = math.min(b-y, n - sub)
        (a-sub) * (b-sub2)
      }

      println(cal(a,b,x,y,n) min cal(b,a,y,x,n))
    }
  }
}

object B extends App {
  import scala.io.StdIn._

  val t = readInt()

  (0 until t).foreach { _ =>
    val Array(a, b, x, y, n) = readLine().split(" ").map(_.toLong)

    val ans = {
      val c = (a - n) max x
      val d = (b - n + a - c) max y
      c * d
    } min {
      val c = (b - n) max y
      val d = (a - n + b - c) max x
      c * d
    }

    println(ans)
  }
}

import scala.collection.mutable.ArrayBuffer

object B extends App {
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer
  import scala.io.Source
  import scala.io.Codec

  /* Implicit methods */
  implicit def intWithTimes(n: Int) = {
    new {
      def times(f: => Unit): Unit = 1.to(n).foreach { _ => f }
    }
  }
  /* Implicit methods */

  //  val in = new CustomScanner(Source.fromResource("input.txt").mkString)
  val in  = new CustomScanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val inputLines = in.nextInt()

    1.to(inputLines)
      .foreach(i => {
        val a = in.nextInt()
        val b = in.nextInt()
        val x = in.nextInt()
        val y = in.nextInt()
        val n = in.nextInt()

        val r1     = findR(a, b, x, y, n)
        val r2     = findR(b, a, y, x, n)
        val result = math.min(r1, r2)
        println(result)

      })
  }

  def findR(a: Int, b: Int, x: Int, y: Int, n: Int) = {
    val (a1, r) = if (a - x <= n) (a - (a - x), n - (a - x)) else (a - n, 0)
    val b1      = if (b - y <= r) b - (b - y) else b - r
    a1.toLong * b1.toLong
  }

  try {
    solve()
  } catch {
    case ex: Exception =>
      println(ex)
      sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }

  /**
    * Util methods
    */

  def printArr[T](in: Array[T]) = {
    in.foreach(print)
    println()
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class CustomScanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {

    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = {
      Iterator
        .continually(reader.readLine())
        .takeWhile(_ != null)
        .map(new StringTokenizer(_))
        .filter(_.hasMoreTokens)
    }

    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] =
      current.find(_.hasMoreTokens) orElse {
        current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
        current
      }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
     * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextLineInt(n: Int): ArrayBuffer[Int] = {
      var data = ArrayBuffer[Int]()
      n.times({
        data += nextInt()
      })
      data
    }

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

    override def next(): String = tokenizer().get.nextToken()

    override def hasNext: Boolean = tokenizer().nonEmpty

    override def close(): Unit = reader.close()
  }
}

object CodeforcesRound667b {

  import java.io.{BufferedReader, PrintStream}

  import scala.io.Source

  def main(args: Array[String]): Unit = {
    exec(Source.stdin.bufferedReader, System.out)
  }

  def exec(implicit
           reader: BufferedReader,
           writer: PrintStream): Unit = {
    val t: Int = rl_int
    (1 to t).foreach(_ => test())
  }

  def test()
          (implicit
           reader: BufferedReader,
           writer: PrintStream): Unit = {
    var Array(a, b, x, y, n) = rll_long
    val res =
      Math.min(
        cmp(a, b, x, y, n),
        cmp(b, a, y, x, n),
      )
    writer.println(res)
  }

  def cmp(a_ : Long, b_ : Long, x_ : Long, y_ : Long, n_ : Long): Long = {
    var a = a_
    var b = b_
    var x = x_
    var y = y_
    var n = n_
    val diff1 = Math.min(a - x, n)
    a -= diff1
    n -= diff1
    val diff2 = Math.min(b - y, n)
    b -= diff2
    n -= diff2
    a * b
  }

  def sqr(a: Long): Long = a * a

  def rl(implicit reader: BufferedReader): String = reader.readLine
  def rll(implicit reader: BufferedReader): Array[String] = reader.readLine.split(' ')

  def rl_bool(implicit reader: BufferedReader): Boolean = rl.toBoolean
  def rl_byte(implicit reader: BufferedReader): Byte = rl.toByte
  def rl_short(implicit reader: BufferedReader): Short = rl.toShort
  def rl_int(implicit reader: BufferedReader): Int = rl.toInt
  def rl_long(implicit reader: BufferedReader): Long = rl.toLong
  def rl_float(implicit reader: BufferedReader): Float = rl.toFloat
  def rl_double(implicit reader: BufferedReader): Double = rl.toDouble

  def rll_bool(implicit reader: BufferedReader): Array[Boolean] = rll.map(_.toBoolean)
  def rll_byte(implicit reader: BufferedReader): Array[Byte] = rll.map(_.toByte)
  def rll_short(implicit reader: BufferedReader): Array[Short] = rll.map(_.toShort)
  def rll_int(implicit reader: BufferedReader): Array[Int] = rll.map(_.toInt)
  def rll_long(implicit reader: BufferedReader): Array[Long] = rll.map(_.toLong)
  def rll_float(implicit reader: BufferedReader): Array[Float] = rll.map(_.toFloat)
  def rll_double(implicit reader: BufferedReader): Array[Double] = rll.map(_.toDouble)

}

//package codeforces.contests._1409

object MinimumProduct {
  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {

      val Array(a, b, x, y, n) = io.StdIn.readLine.split(" ").map(_.toInt)

      val (f, s) = {
        if (n == 0) (a, b)
        else if (n == 1) ((a max b) - 1, a min b)
        else if (a == x) (a, (b - n) max y)
        else if (b == y) ((a - n) max x, b)
        else {
          val aD = (a - n) max x
          val bD = (b - n) max y

          if (aD <= bD) (aD, (b - (n - (a - aD))) max y)
          else ((a - (n - (b - bD))) max x, bD)
        }
      }

      println(f.toLong * s.toLong)
    }
  }
}

object B extends App {
  import scala.io.StdIn._

  val t = readInt()

  (0 until t).foreach { _ =>
    val Array(a, b, x, y, n) = readLine().split(" ").map(_.toLong)

    val ans =
      if (a < b) {
        val c = (a - n) max x
        val d = (b - n + a - c) max y
        c * d
      } else {
        val c = (b - n) max y
        val d = (a - n + b - c) max x
        c * d
      }

    println(ans)
  }
}

import scala.collection.mutable.ArrayBuffer

object B extends App {
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer
  import scala.io.Source
  import scala.io.Codec

  /* Implicit methods */
  implicit def intWithTimes(n: Int) = {
    new {
      def times(f: => Unit): Unit = 1.to(n).foreach { _ => f }
    }
  }
  /* Implicit methods */

  //  val in = new CustomScanner(Source.fromResource("input.txt").mkString)
  val in  = new CustomScanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val inputLines = in.nextInt()

    inputLines.times {
      val a = in.nextInt()
      val b = in.nextInt()
      val x = in.nextInt()
      val y = in.nextInt()
      val n = in.nextInt()

      val r1 = findR(a, b, x, y, n)
      val r2 = findR(b, a, y, x, n)
      printf("%.0f\n", math.min(r1, r2))
    }
  }

  def findR(a: Int, b: Int, x: Int, y: Int, n: Int) = {
    val (a1, r) = if (a - x <= n) (a - (a - x), n - (a - x)) else (a - n, 0)
    val b1      = if (b - y <= r) b - (b - y) else b - r
    a1.toDouble * b1.toDouble
  }

  try {
    solve()
  } catch {
    case ex: Exception =>
      println(ex)
      sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }

  /**
    * Util methods
    */

  def printArr[T](in: Array[T]) = {
    in.foreach(print)
    println()
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class CustomScanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {

    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = {
      Iterator
        .continually(reader.readLine())
        .takeWhile(_ != null)
        .map(new StringTokenizer(_))
        .filter(_.hasMoreTokens)
    }

    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] =
      current.find(_.hasMoreTokens) orElse {
        current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
        current
      }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
      * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextLineInt(n: Int): ArrayBuffer[Int] = {
      var data = ArrayBuffer[Int]()
      n.times({
        data += nextInt()
      })
      data
    }

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

    override def next(): String = tokenizer().get.nextToken()

    override def hasNext: Boolean = tokenizer().nonEmpty

    override def close(): Unit = reader.close()
  }
}

import scala.collection.mutable.ArrayBuffer

object B extends App {
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer
  import scala.io.Source
  import scala.io.Codec

  /* Implicit methods */
  implicit def intWithTimes(n: Int) = {
    new {
      def times(f: => Unit): Unit = 1.to(n).foreach { _ => f }
    }
  }
  /* Implicit methods */

  //  val in = new CustomScanner(Source.fromResource("input.txt").mkString)
  val in  = new CustomScanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val inputLines = in.nextInt()

    1.to(inputLines)
      .foreach(i => {
        val a = in.nextInt()
        val b = in.nextInt()
        val x = in.nextInt()
        val y = in.nextInt()
        val n = in.nextInt()

        if (i == 4918) {
          println(a, b, x, y, n)
          val r1 = findR(a, b, x, y, n)
          val r2 = findR(b, a, y, x, n)
          printf("%.0f\n", math.min(r1, r2))
        }

      })
  }

  def findR(a: Int, b: Int, x: Int, y: Int, n: Int) = {
    val (a1, r) = if (a - x <= n) (a - (a - x), n - (a - x)) else (a - n, 0)
    val b1      = if (b - y <= r) b - (b - y) else b - r
    a1.toDouble * b1.toDouble
  }

  try {
    solve()
  } catch {
    case ex: Exception =>
      println(ex)
      sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }

  /**
    * Util methods
    */

  def printArr[T](in: Array[T]) = {
    in.foreach(print)
    println()
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class CustomScanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {

    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = {
      Iterator
        .continually(reader.readLine())
        .takeWhile(_ != null)
        .map(new StringTokenizer(_))
        .filter(_.hasMoreTokens)
    }

    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] =
      current.find(_.hasMoreTokens) orElse {
        current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
        current
      }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
     * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextLineInt(n: Int): ArrayBuffer[Int] = {
      var data = ArrayBuffer[Int]()
      n.times({
        data += nextInt()
      })
      data
    }

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

    override def next(): String = tokenizer().get.nextToken()

    override def hasNext: Boolean = tokenizer().nonEmpty

    override def close(): Unit = reader.close()
  }
}

import scala.collection.mutable.ArrayBuffer

object B extends App {
  import java.io._
  import java.nio.file.{Files, Path}
  import java.util.StringTokenizer
  import scala.io.Source
  import scala.io.Codec

  /* Implicit methods */
  implicit def intWithTimes(n: Int) = {
    new {
      def times(f: => Unit): Unit = 1.to(n).foreach { _ => f }
    }
  }
  /* Implicit methods */

  //  val in = new CustomScanner(Source.fromResource("input.txt").mkString)
  val in  = new CustomScanner(System.in)
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val inputLines = in.nextInt()

    1.to(inputLines)
      .foreach(i => {
        val a = in.nextInt()
        val b = in.nextInt()
        val x = in.nextInt()
        val y = in.nextInt()
        val n = in.nextInt()

        if (i == 4918) {
          println(a, b, x, y, n)
          val r1 = findR(a, b, x, y, n)
          val r2 = findR(b, a, y, x, n)
          printf("%.0f\n", math.min(r1, r2))
        } else if( i <= 7){

          val r1 = findR(a, b, x, y, n)
          val r2 = findR(b, a, y, x, n)
          printf("%.0f\n", math.min(r1, r2))
        }

      })
  }

  def findR(a: Int, b: Int, x: Int, y: Int, n: Int) = {
    val (a1, r) = if (a - x <= n) (a - (a - x), n - (a - x)) else (a - n, 0)
    val b1      = if (b - y <= r) b - (b - y) else b - r
    a1.toDouble * b1.toDouble
  }

  try {
    solve()
  } catch {
    case ex: Exception =>
      println(ex)
      sys.exit(9999)
  } finally {
    out.flush()
    out.close()
  }

  /**
    * Util methods
    */

  def printArr[T](in: Array[T]) = {
    in.foreach(print)
    println()
  }

  /**
    * Scala implementation of a faster java.util.Scanner
    * See: http://codeforces.com/blog/entry/7018
    */
  class CustomScanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {

    def this(reader: BufferedReader) = this(new LineNumberReader(reader))

    def this(reader: Reader) = this(new BufferedReader(reader))

    def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))

    def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))

    def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)

    def this(str: String) = this(new StringReader(str))

    private[this] val tokenizers = {
      Iterator
        .continually(reader.readLine())
        .takeWhile(_ != null)
        .map(new StringTokenizer(_))
        .filter(_.hasMoreTokens)
    }

    private[this] var current: Option[StringTokenizer] = None

    @inline private[this] def tokenizer(): Option[StringTokenizer] =
      current.find(_.hasMoreTokens) orElse {
        current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
        current
      }

    /**
      * Unlike Java's scanner which returns till end of current line, this actually returns the next line
      *
     * @see line() if you want the Java behaviour
      */
    def nextLine(): String = {
      current = None // reset
      reader.readLine()
    }

    def lineNumber: Int = reader.getLineNumber

    def line(): String = tokenizer().get.nextToken("\n\r")

    def nextLineInt(n: Int): ArrayBuffer[Int] = {
      var data = ArrayBuffer[Int]()
      n.times({
        data += nextInt()
      })
      data
    }

    def nextString(): String = next()

    def nextChar(): Char = next().ensuring(_.length == 1).head

    def nextBoolean(): Boolean = next().toBoolean

    def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)

    def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)

    def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)

    def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)

    def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)

    def nextFloat(): Float = next().toFloat

    def nextDouble(): Double = next().toDouble

    def nextBigDecimal(): BigDecimal = BigDecimal(next())

    override def next(): String = tokenizer().get.nextToken()

    override def hasNext: Boolean = tokenizer().nonEmpty

    override def close(): Unit = reader.close()
  }
}


object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val n = lines.next().toInt
  val line = lines.next()
  if (n > 26)
    println(-1)
  else
    println(n - line.distinct.length)
}

object Solution {

	def main(arg: Array[String]) {
		val sc = new java.util.Scanner(System.in)
		val n = sc.nextInt
		val s = sc.next
		val charCounts = new Array[Int](26)
		for (i <- 0 until s.length) {
			val idx = s.charAt(i) - 'a'
			charCounts(idx) = charCounts(idx) + 1
		}
		val unused = charCounts.foldLeft(0)((a,b) => a + (if (b == 0) 1 else 0))
		val sum = charCounts.foldLeft(0)((a,b) => a + (if (b > 1) b-1 else 0))
		println(if (unused >= sum) sum else -1)
	}
}

object B672 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val in = read
    if(in.length > 26) {
      println("-1")
    } else {
      val res = in.length - in.distinct.length
      println(res)
    }
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import scala.io.StdIn

/**
  * Created by whimsy on 16/7/17.
  */

object P672B extends App {
    val n = StdIn.readInt()

    val content = StdIn.readLine()

    var set = Set[Char]()

    val answer = if (n > 26) {
        -1
    } else {
        content.foreach(e =>
            set += e
        )

        content.size - set.size
    }

    println(answer)
}


/**
 * Created by ashione on 14-6-19.
 */
object CF441A {
  import java.util.Scanner
  val in = new Scanner(System.in)

  def main(arg:Array[String]):Unit = {

    val itemNum = in.nextInt
    val valeraPrice = in.nextInt
    val ans:List[Int] = (for(i <- 1 to itemNum if isDeal(valeraPrice)) yield i).toList
    println(ans.length)
    ans.foreach(x=>print(x+" "))
  }
  def isDeal(price:Int):Boolean = {
    val sellerNum = in.nextInt
    val sl: List[Int] = {
      for (i <- 1 to sellerNum) yield in.nextInt
    }.toList
    !sl.forall(x => x >= price)
  }
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, v) = in.next().split(" ").map(_.toInt)
  val r = Range(1, n + 1).map(i => (i, in.next().split(" ").map(_.toInt).tail.min)).filter(_._2 < v).map(_._1)
  println(r.length)
  println(r.mkString(" "))
}

object a {

  def main (args: Array[String]){
    var Array(n,k) = readLine.split(" ").map(_.toInt)
    var ans = 0
    var used = new Array[Int](n+1)
    for (i <- 0 until n){
      var x = readLine.split(" ").map(_.toInt)
      var bl =false
      for (j <- 1 to x(0))
        if (x(j)<k && !bl)
        	{ans +=1;bl=true;used(ans)=i+1}
    }
    println(ans)
    for (i <- 1 to ans)
      print(used(i)+" ")
  }

}

object A441 {
  @inline def read = scala.io.StdIn.readLine

  @inline def tokenizeLine = new java.util.StringTokenizer(read)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n, v) = readInts(2)
    var arr = Array[Int]()
    for(i <- 0 until n) {
      val tl = tokenizeLine
      val num = tl.nextToken.toInt
      if(Array.fill(num)(tl.nextToken.toInt).min < v) {
        arr ++= Array(i+1)
      }
    }
    println(arr.length)
    println(arr.mkString(" "))
  }
}

/**
 * I've tried to make this piece of code as readable as possible.
 * Enjoy hacking it!
 */
import scala.collection._

object A extends App {

  def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }
  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }
  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }

  val Array(n, v) = readInts(2)
  val res = mutable.Buffer.empty[Int]

  for (i <- 1 to n) {
    val t2 = tokenizeLine
    val k = t2.nextToken.toInt
    val min = Array.fill(k)(t2.nextToken.toInt).min
    if (min < v) res += i
  }

  println(res.size)
  println(res.mkString(" "))
}

object Template {
	def main(args: Array[String]) {
		var Array(n, l) = readLine.split(" ").map(_.toInt)
		var array : Array[Int] = new Array[Int](n)
		var result = 0
		for(i <- 1 to n){
			var line = readLine.split(" ").map(_.toInt)
			var added = false
			for(j <- 1 to line(0)){
				if(line(j) < l && !added){
					result += 1
					array(i-1) = i
					added = true
				}
			}
		}
		println(result)
		for(i <- array){
			if(i != 0) print(i + " ")
		}
	}
}

import java.util.StringTokenizer

import scala.collection.mutable.ArrayBuilder

object _441A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val v = next.toInt
  val builder = new ArrayBuilder.ofInt
  for (i <- 1 to n) {
    val m = next.toInt
    if ((1 to m).map(i => next.toInt).min < v) builder += i
  }
  val res = builder.result
  println(res.length)
  println(res.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, v) = in.next().split(" ").map(_.toInt)
  println(Range(0, n).map(_ => in.next().split(" ").map(_.toInt).tail.min).count(_ > v))
}


object Main {
def main(args: Array[String]) : Unit = {
    val n = readInt
    val feelings = List("hate", "love")

    def loop(index: Int): String = {
      val feeling = feelings(index % 2)

      if(index == n-1) return s"I $feeling it"

      s"I $feeling that " + loop(index + 1)
    }

    println(loop(0))
  }
}

object tanya extends App{
var a = readInt
var str = ""
val hate = "I hate"
val love = "I love"

for(i <- 0 to a){
    if(i == 1){
        str = str.concat(hate)
    }else if(i >= 2){
        str = str.concat(" that ")
        if(i % 2 == 1){
            str = str.concat(hate)
        }else{
            str = str.concat(love)
        }
    }
}
str = str.concat(" it")
println(str)
}

object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val n = lines.next().toInt
  println((1 to n).map(i => if (i % 2 == 0) "I love " else "I hate ").mkString("", "that ", "it"))
}

object A705 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val str = Array("I hate", "I love")
    println(
      (0 until n).foldLeft(""){ (s, i) =>
        s + " " + str(i%2) + (if(i == n-1) " it" else " that")
      }.trim)
  }
}

import java.util._;

object Main extends App {

  def fun(n: Int, flip: Boolean, acc: String): String = {
    def addPhrase(): String = if (flip) "I hate" else "I love"

    if (n == 0) acc
    else if (n == 1) {
      fun(n - 1, !flip, acc ++ addPhrase() ++ " it ")
    } else {
      fun(n - 1, !flip, acc ++ addPhrase() ++ " that ")
    }
  }

  val sc = new Scanner(System.in);
  val n: Int = sc.nextInt()
  println(fun(n, flip = true, ""))
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _705A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write}
    val n = read[Int]
    val tokens = (1 to n) map {
      case i if i%2 == 1 => "I hate"
      case _ => "I love"
    }
    val ans = tokens.mkString("", " that ", " it")
    write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "YES" else "NO"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any, more: Any*): this.type = {
    printer.print(obj)
    more foreach {i =>
      printer.print(' ')
      printer.print(i)
    }
    this
  }
  def writeOnNextLine(obj: Any, more: Any*): this.type = {
    printer.println()
    write(obj, more: _*)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import scala.io.StdIn._

object Solution {

  def main(args: Array[String]): Unit = {
    val n = readInt
    val ans =
      (1 to n).foldLeft("") {
        case (acc, `n`) if n % 2 == 1 => acc + "I hate it"
        case (acc, `n`) => acc + "I love it"
        case (acc, i) if i % 2 == 1 => acc + "I hate that "
        case (acc, i) => acc + "I love that "
      }
    print(ans)
  }
}

import scala.io.StdIn._

object A extends App {
  val n = readInt()
  val A = Array("I hate", "I love")

  val B = (0 until n).map { i =>
    A(i % 2)
  }

  println(B.mkString(" that ") + " it")

}

object Hulk705A // extends TSolver {
                     extends App {
    import java.io.{InputStream, PrintStream}
    import java.util.Scanner
    solve(System.in,System.out)
    def solve(in: InputStream, out: PrintStream): Unit = {
        val scanner = new Scanner(in)
      val n = scanner.nextInt()
      val s = (1 to n).map{i => s"I ${if(i%2==1)"hate" else "love" }"}.mkString(" that ") + " it"
      out.println(s)
    }
}

import scala.io.StdIn

object Codeforces705A extends App {
  var n = StdIn.readLine().toInt
  var love = false
  while (n > 0) {
    if (love) {
      print("I love " + (if (n == 1) "it" else "that "))
    } else {
      print("I hate " + (if (n == 1) "it" else "that "))
    }
    love = !love
    n -= 1
  }
}

import scala.io.StdIn

object Main2 extends App {
  val feelingNumber = StdIn.readInt()
  val res = 0.until(feelingNumber)
    .map(index => s"I ${if (index % 2 == 0) "hate" else "love"}")
    .mkString(" that ") + " it"
  println(res)
}

import java.util

import scala.util.Sorting
import scala.io.StdIn

object App {

  def main(args: Array[String]) {

    val max = 1000000007;
    val n = readInt()

    var s = ""

    for(i <- 0 until n) {
      if(i % 2 == 0) {
        s+="I hate that "
      } else {
        s+="I love that "
      }
    }

    println(s.reverse.replaceFirst("taht", "ti").reverse)

  }

  def readInt(): Int = StdIn.readInt()

  def readInts(): Array[Int] = StdIn.readLine().split(" ").map(_.toInt)

  def readTuple(): (Int, Int) = {
    val line = readInts
    (line(0), line(1))
  }

}

import scala.io.StdIn._

object TaskA extends App {
  println((1 to readInt map(i => if (i % 2 == 0) "I love" else "I hate" ) mkString " that ") + " it")
}

import scala.io.StdIn._

object Solution {
	var n = readInt

	def main(args:Array[String]):Unit = {

		for(i <- 1 to n-1) {
			if(i%2 == 0) print("I love that ")
			else print("I hate that ")
		}

		if(n % 2 == 0) print("I love it\n")
		else print("I hate it\n")

	}
}

object Main {
  def main(args: Array[String]) : Unit = {
    val n = readInt
    val feelings = List("hate", "love")

    def loop(index: Int, res: String): String = {
      val feeling = feelings(index % 2)

      if(index == n-1) return res + s"I $feeling it"

      loop(index + 1, res + s"I $feeling that ")
    }

    println(loop(0, ""))
  }
}

object A705 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val str = Array("I hate that", "I love that")
    println((0 until n).foldLeft(""){(s, i) => s + " " + str(i%2)}.trim)
  }
}

import scala.io.StdIn

object Codeforces705A extends App {
  var n = StdIn.readLine().toInt
  while (n > 0) {
    if (n % 2 == 0) {
      print("I love " + (if (n == 1) "it" else "that "))
    } else {
      print("I hate " + (if (n == 1) "it" else "that "))
    }
    n -= 1
  }
}


object CF {
   def isVowel(c: Char): Boolean =
  	List('a','e','i','o','u', 'y') exists (a => a == Character.toLowerCase(c))
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n = sc.nextInt()
    var s = sc.next()
    var i = 0
    while (i < n) {
      var j = i + 1
      if(isVowel(s(i))) {
        var cnt = 1
        while (j < n && s(j) == s(i)) {
          j = j + 1
          cnt = cnt + 1
        }
        if (s(i) == 'e' || s(i) == 'o') {
          if (cnt == 2) {
            print(s(i))
          }
        }
      }
      print(s(i))
      i = j
    }
  }
}

object Main {
    def main(args: Array[String]) {
        var n = readInt
        var s = readLine
        var i = 0
        if ( n == 0 ) {
            sys.exit(0)
        }
        print(s.charAt(0))
        for (i <- 1 to n-1) {
                if ( ! ( ( s.charAt(i) == s.charAt(i-1) && ( s.charAt(i) == 'a' || s.charAt(i) == 'i' || s.charAt(i) == 'u' || s.charAt(i) == 'y'  ) ) ||
                       ( s.charAt(i) == s.charAt(i-1) && ( ( i > 1 && s.charAt(i) == s.charAt(i-2) ) || ( i != n-1 && s.charAt(i+1) == s.charAt(i) ) ) && ( s.charAt(i) == 'o' || s.charAt(i) == 'e' ) ) ) )
                print(s.charAt(i))
        }
        println("")
    }
}

object Main extends App {
    val n = readInt
    val s = readLine
    var pc = ' '
    var count = 0
    for (c <- s) {
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
            if (c == pc) {
                count += 1
            } else {
                if (count > 0) {
                    if (count == 2 && ((pc == 'o' || pc == 'e'))) {
                        print(pc)
                        print(pc)
                    } else {
                        print(pc)
                    }
                }
                pc = c
                count = 1
            }
        } else {
            if (count > 0) {
                if (count == 2 && ((pc == 'o' || pc == 'e'))) {
                    print(pc)
                    print(pc)
                } else {
                    print(pc)
                }
            }

            count = 0
            print(c)
        }
        pc = c
    }
    if (count > 0) {
        if (count == 2 && ((pc == 'o' || pc == 'e'))) {
            print(pc)
            print(pc)
        } else {
            print(pc)
        }
    }
    println()
}

object CF {
   def isVowel(c: Char): Boolean =
  	List('a','e','i','o','u') exists (a => a == Character.toLowerCase(c))
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n = sc.nextInt()
    var s = sc.next()
    var i = 0
    while (i < n) {
      var j = i + 1
      if(isVowel(s(i))) {
        while (j < n && s(j) == s(i)) {
          j = j + 1
        }
      }
      print(s(i))
      i = j
    }
  }
}

object CF {
   def isVowel(c: Char): Boolean =
  	List('a','e','i','o','u') exists (a => a == Character.toLowerCase(c))
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n = sc.nextInt()
    var s = sc.next()
    var i = 0
    while (i < n) {
      var j = i + 1
      if(isVowel(s(i))) {
        var cnt = 1
        while (j < n && s(j) == s(i)) {
          j = j + 1
          cnt = cnt + 1
        }
        if (s(i) == 'e' || s(i) == 'o') {
          if (cnt == 2) {
            print(s(i))
          }
        }
      }
      print(s(i))
      i = j
    }
  }
}


import sun.management.counter.Counter

import scala.:+
import scala.+:
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLong
import scala.io.StdIn.readInt
import scala.io.StdIn.readLine

object Solution extends App {

  //=====Solution=========
  val testNumber = readInt()
  1.to(testNumber).foreach { _ =>
    val Array(n, k) = readInts()
    k match {
      case 1 =>
        println("YES")
        1.to(n).foreach(v => println(v))
      case _ if (n % 2 == 0) =>
        println("YES")
        val a = 1.to(k * n / 2).map(_ * 2 - 1)
        val b = 1.to(k * n / 2).map(_ * 2)
        a.grouped(k).map(_.mkString(" ")).foreach(println(_))
        b.grouped(k).map(_.mkString(" ")).foreach(println(_))
      case _ => println("NO")
    }
  }

  3 * 4
  //1 3 5 7 9 11
  //2 4 6 8 10 12

  //4 * 3
  //1 3 5
  //7 9 11
  //2 4 6
  //8 10 12

  //1 3 5 7 9 11
  //2 4 6 8 10 12
  //13 15 17 19 21 23
  //14 16 18 20 22 24
  //25 27 29 31 33 35
  //26 28 30 32 34 36

  //1 3 5
  //7 9 11
  //2 4 6
  //8 10 12

  //=====Template=========
  def readInts(): Array[Int] = readLine().split(" ").map(_.toInt)
  def readLongs(): Array[Long] = readLine().split(" ").map(_.toLong)
  def readChars(): Array[Char] = readLine().toCharArray
  def asInt(b: Boolean) = if (b) 1 else 0

  class MutableMultiSet[T](seq: Seq[T])(implicit val ord: Ordering[T]) {
    val multiSet: mutable.TreeMap[T, Int] = new mutable.TreeMap[T, Int]()
    seq.foreach { value => add(value) }
    def contains(value: T) = multiSet.contains(value)
    def max: T = multiSet.last._1
    def min: T = multiSet.head._1
    def add(value: T) = multiSet.get(value) match {
      case None => multiSet(value) = 1
      case Some(counter) => multiSet(value) = counter + 1
    }
    def remove(value: T) = multiSet.get(value) match {
      case None => None
      case Some(1) => multiSet.remove(value)
      case Some(counter) => multiSet(value) = counter - 1
    }
  }
}

import scala.io.Source

object Contest extends App {
  def logic(n: Int, k: Int): Unit = {
    val max = n * k
    if (k == 1) {
      println("YES")
      println(Range.inclusive(1, max).mkString("\n"))
    } else if (max % 2 == 0 && n != 1 && (max / 2) % k == 0) {
      println("YES")
      Range(1, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
      Range.inclusive(2, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
    } else println("NO")
  }

  val input = Source.fromInputStream(System.in).getLines()
  val t = input.next().toInt
  val nk = new Array[(Int, Int)](t)
  for (i <- 0 until t) {
    val Array(n, k) = input.next().split(" ")
    nk(i) = (n.toInt, k.toInt)
  }

  for (i <- 0 until t) {
    val (n, k) = nk(i)
    logic(n, k)
  }
}

import java.io._
import java.util.StringTokenizer
import scala.+:
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object Main extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class fenwick(n: Int) {
        val tree = new Array[Long](n+1)
        def query(ind: Int): Long = {
            var idx = ind
            var ans = 0L
            while (idx > 0) {
                ans += tree(idx)
                idx -= (idx & -idx)
            }
            return ans
        }
        def update(ind: Int, value: Long): Unit = {
            var idx = ind
            while (idx <= n) {
                tree(idx) += value
                idx += (idx & -idx)
            }
        }
    }

    case class pair(var a: Int, var b: Int)extends Ordered[pair] {
        override def compare(that: pair): Int = {
            return (a).compareTo(that.a)
        }
    }

    def gcd(a: Int, b: Int): Int = b match {
        case 0 => a
        case n => gcd(b, a % b)
    }
    val rem = 1000000007
    val maxn = 200010
    val mapp = mutable.Map[pair, Int]()

    val t = readInt()

    for (tt <- 1 to t) {
        val n = readInt()
        val k = readInt()
        if (n % 2 == 1 && k > 1) {
            writer.println("NO")
        } else {
            writer.println("YES")
            var pl = 1
            var pr = 2
            for (i <- 1 to n) {
                for (j <- 1 to k) {
                    if (i % 2 == 1) {
                        writer.print(pl + " ")
                        pl += 2
                    } else {
                        writer.print(pr + " ")
                        pr += 2
                    }
                }
                writer.println()
            }
        }

        def check(kk: Long, fi: Long): Boolean = {
            return false
        }
        def bs(st:Long, en:Long, fi:Long): Long = {
            if (en - st <= 1L) {
                if (check(st, fi))
                    return st
                else
                    return en
            }
            val mid = (st + en) / 2L
            if (check(mid, fi))
                return bs(st, mid, fi)
            else
                return bs(mid, en, fi)
        }
    }
    writer.flush()
}

import scala.io.Source

object Contest extends App {
  def logic(n: Int, k: Int): Unit = {
    val max = n * k
    if (k == 1) {
      println("YES")
      println(Range.inclusive(1, max).mkString("\n"))
    } else if (max % 2 == 0 && n != 1) {
      println("YES")
      Range(1, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
      Range.inclusive(2, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
    } else println("NO")
  }

  val input = Source.fromInputStream(System.in).getLines()
  val t = input.next().toInt
  val nk = new Array[(Int, Int)](t)
  for (i <- 0 until t) {
    val Array(n, k) = input.next().split(" ")
    nk(i) = (n.toInt, k.toInt)
  }

  for (i <- 0 until t) {
    val (n, k) = nk(i)
    logic(n, k)
  }
}

import scala.io.Source

object Contest extends App {
  def logic(n: Int, k: Int): Unit = {
    val max = n * k
    if (k == 1) {
      println("YES")
      println(Range.inclusive(1, max).mkString("\n"))
    } else if (max % 2 == 0) {
      println("YES")
      Range(1, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
      Range.inclusive(2, max, 2).grouped(k).map(_.mkString(" "))
        .foreach(println)
    } else println("NO")
  }

  val input = Source.fromInputStream(System.in).getLines()
  val t = input.next().toInt
  val nk = new Array[(Int, Int)](t)
  for (i <- 0 until t) {
    val Array(n, k) = input.next().split(" ")
    nk(i) = (n.toInt, k.toInt)
  }

  for (i <- 0 until t) {
    val (n, k) = nk(i)
    logic(n, k)
  }
}

import scala.io.Source

object Contest extends App {
  def logic(n: Int, k: Int): Unit = {
    val max = n * k
    if (k == 1) {
      println("YES")
      println(Range.inclusive(1, max).mkString("\n"))
    } else if (max % 2 == 0) {
      println("YES")
      Range(1, max, 2).sliding(k).map(_.mkString(" "))
        .foreach(println)
      val b = Range.inclusive(2, max, 2).sliding(k).map(_.mkString(" "))
        .foreach(println)
    } else println("NO")
  }

  val input = Source.fromInputStream(System.in).getLines()
  val t = input.next().toInt
  val nk = new Array[(Int, Int)](t)
  for (i <- 0 until t) {
    val Array(n, k) = input.next().split(" ")
    nk(i) = (n.toInt, k.toInt)
  }

  for (i <- 0 until t) {
    val (n, k) = nk(i)
    logic(n, k)
  }
}

import scala.collection.mutable.ArrayBuffer
import scala.io.Source

object Contest extends App {
  def logic(n: Int, k: Int): Unit = {
    if (k == 1) {
      println("YES")
      val max = n * k
      println(Range.inclusive(1, max).mkString("\n"))
    } else if (k == 2) {
      println("YES")
      val max = n * k
      val res = new ArrayBuffer[String](n)
      for (i <- 1 until max by 4) {
        res.append(s"$i ${i + 2}")
      }
      for (i <- 2 until max by 4) {
        res.append(s"$i ${i + 2}")
      }
      println(res.mkString("\n"))
    } else println("NO")
  }

  val input = Source.fromInputStream(System.in).getLines()
  val t = input.next().toInt
  val nk = new Array[(Int, Int)](t)
  for (i <- 0 until t) {
    val Array(n, k) = input.next().split(" ")
    nk(i) = (n.toInt, k.toInt)
  }

  for (i <- 0 until t) {
    val (n, k) = nk(i)
    logic(n, k)
  }
}

import sun.management.counter.Counter

import scala.:+
import scala.+:
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLong
import scala.io.StdIn.readInt
import scala.io.StdIn.readLine

object Solution extends App {

  //=====Solution=========
  val testNumber = readInt()
  1.to(testNumber).foreach { _ =>
    val Array(n, k) = readInts()
    k match {
      case 1 =>
        println("YES")
        1.to(n).foreach(v => println(v))
      case 2 if n % 2 == 0 =>
        println("YES")
        1.to(n).foreach(v => println(s"$v ${v + n}"))
      case _ if (n == 2) =>
        println("YES")
        println(1.to(k).map(_ * 2 - 1).mkString(" "))
        println(1.to(k).map(_ * 2).mkString(" "))
      case _ => println("NO")
    }
  }

  //1 3 5
  //2 4 6

  //1 3 5 7 9 11
  //2 4 6 8 10 12

  //=====Template=========
  def readInts(): Array[Int] = readLine().split(" ").map(_.toInt)
  def readLongs(): Array[Long] = readLine().split(" ").map(_.toLong)
  def readChars(): Array[Char] = readLine().toCharArray
  def asInt(b: Boolean) = if (b) 1 else 0

  class MutableMultiSet[T](seq: Seq[T])(implicit val ord: Ordering[T]) {
    val multiSet: mutable.TreeMap[T, Int] = new mutable.TreeMap[T, Int]()
    seq.foreach { value => add(value) }
    def contains(value: T) = multiSet.contains(value)
    def max: T = multiSet.last._1
    def min: T = multiSet.head._1
    def add(value: T) = multiSet.get(value) match {
      case None => multiSet(value) = 1
      case Some(counter) => multiSet(value) = counter + 1
    }
    def remove(value: T) = multiSet.get(value) match {
      case None => None
      case Some(1) => multiSet.remove(value)
      case Some(counter) => multiSet(value) = counter - 1
    }
  }
}

import sun.management.counter.Counter

import scala.:+
import scala.+:
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLong
import scala.io.StdIn.readInt
import scala.io.StdIn.readLine

object Solution extends App {

  //=====Solution=========
  val testNumber = readInt()
  1.to(testNumber).foreach { _ =>
    val Array(n, k) = readInts()
    k match {
      case 1 =>
        println("YES")
        1.to(n).foreach(v => println(v))
      case 2 if n % 2 == 0 =>
        println("YES")
        1.to(n).foreach(v => println(s"$v ${v + n}"))
      case _ => println("NO")
    }
  }

  //=====Template=========
  def readInts(): Array[Int] = readLine().split(" ").map(_.toInt)
  def readLongs(): Array[Long] = readLine().split(" ").map(_.toLong)
  def readChars(): Array[Char] = readLine().toCharArray
  def asInt(b: Boolean) = if (b) 1 else 0

  class MutableMultiSet[T](seq: Seq[T])(implicit val ord: Ordering[T]) {
    val multiSet: mutable.TreeMap[T, Int] = new mutable.TreeMap[T, Int]()
    seq.foreach { value => add(value) }
    def contains(value: T) = multiSet.contains(value)
    def max: T = multiSet.last._1
    def min: T = multiSet.head._1
    def add(value: T) = multiSet.get(value) match {
      case None => multiSet(value) = 1
      case Some(counter) => multiSet(value) = counter + 1
    }
    def remove(value: T) = multiSet.get(value) match {
      case None => None
      case Some(1) => multiSet.remove(value)
      case Some(counter) => multiSet(value) = counter - 1
    }
  }
}

import java.io._
import java.util.StringTokenizer
import scala.+:
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object Main extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class fenwick(n: Int) {
        val tree = new Array[Long](n+1)
        def query(ind: Int): Long = {
            var idx = ind
            var ans = 0L
            while (idx > 0) {
                ans += tree(idx)
                idx -= (idx & -idx)
            }
            return ans
        }
        def update(ind: Int, value: Long): Unit = {
            var idx = ind
            while (idx <= n) {
                tree(idx) += value
                idx += (idx & -idx)
            }
        }
    }

    case class pair(var a: Int, var b: Int)extends Ordered[pair] {
        override def compare(that: pair): Int = {
            return (a).compareTo(that.a)
        }
    }

    def gcd(a: Int, b: Int): Int = b match {
        case 0 => a
        case n => gcd(b, a % b)
    }
    val rem = 1000000007
    val maxn = 200010
    val mapp = mutable.Map[pair, Int]()

    val t = readInt()

    for (tt <- 1 to t) {
        val n = readInt()
        val k = readInt()
        if (n * k % 2 == 1 && k > 1) {
            writer.println("NO")
        } else {
            writer.println("YES")
            var pl = 1
            var pr = 2
            for (i <- 1 to n) {
                for (j <- 1 to k) {
                    if (i % 2 == 1) {
                        writer.print(pl + " ")
                        pl += 2
                    } else {
                        writer.print(pr + " ")
                        pr += 2
                    }
                }
                writer.println()
            }
        }

        def check(kk: Long, fi: Long): Boolean = {
            return false
        }
        def bs(st:Long, en:Long, fi:Long): Long = {
            if (en - st <= 1L) {
                if (check(st, fi))
                    return st
                else
                    return en
            }
            val mid = (st + en) / 2L
            if (check(mid, fi))
                return bs(st, mid, fi)
            else
                return bs(mid, en, fi)
        }
    }
    writer.flush()
}


object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, W = ni()
    val A = na(N)
    var upper = W
    var lower = 0
    REP(N) { i =>
      upper = min(W, upper + A(i))
      lower = max(0, lower + A(i))
    }
    out.println(max(0, upper - lower + 1))
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Long]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

import scala.io.StdIn
object CF978E extends App {
  val Array(n, w) = StdIn.readLine.split(' ').map(_.toInt)
  val as = StdIn.readLine.split(' ').map(_.toInt)
  val passengers = as.scanLeft(0){_+_}
  // x >= -passengers.min
  // x <= w - passengers.max
  val possibilities = (w - passengers.max + passengers.min + 1) max 0
  println(possibilities)
}