@ptn = 0

# n:検索対象, previn:呼出元メソッドで選出された数値, sum:合計値, d:探索深さ
def sum4Integers(n, previn=0, sum=0, d=1, hist=[])
  (previn..9).each do |i|
    #p "n:#{n}, previn:#{previn}, sum:#{sum}, d:#{d}, i:#{i}, #{hist}"
    return if sum > n || i > n # 合計値or候補番号が検索対象値を上回ったら検索打ち切り
    if d != 4 then
      sum4Integers(n, i, sum+i, d+1, hist+[i])
    elsif (d == 4) && (sum+i == n) then     
      hist += [i]
      facttimes = 1
      hist.uniq.each do |num|
        facttimes *= fact(hist.count(num))
      end
      @ptn += fact(4)/facttimes
      return
    end
  end
end

# 階乗計算
def fact(n)
  n == 1 ? 1 : n*fact(n-1)
end

while n = gets
  n = n.chomp.to_i
  @ptn = 0
  sum4Integers(n)
  p @ptn
end

