import java.util.*;

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

  }

  public int maxIceCream(int[] costs, int coins) {
    Arrays.sort(costs);
    int index = 0;
    while (coins >= 0 && index < costs.length) {
      if (costs[index] <= coins) {
        coins = coins - costs[index];
      } else {
        break;
      }
      index++;
    }
    return index;
  }
}
