#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  bool neg = false;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') neg = true, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  if (neg) x = -x;
  return x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 500;
int n, m, c[N + 2], dp[N + 2][N + 2];
const int mod = 998244353;
void input() {
  cin >> n >> m;
  for (int _b = m, i = 1; i <= _b; ++i) cin >> c[i];
}
int dfs(int l, int r) {
  if (dp[l][r]) return dp[l][r];
  if (l >= r) return dp[l][r] = 1;
  int p = l;
  for (int _b = r, i = l; i <= _b; ++i)
    if (c[i] < c[p]) p = i;
  int suml = 0, sumr = 0;
  for (int _b = p, i = l; i <= _b; ++i)
    suml = (suml + 1ll * dfs(l, i - 1) * dfs(i, p - 1) % mod) % mod;
  for (int _b = r, i = p; i <= _b; ++i)
    sumr = (sumr + 1ll * dfs(p + 1, i) * dfs(i + 1, r) % mod) % mod;
  return dp[l][r] = 1ll * suml * sumr % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  input();
  cout << dfs(1, m);
  return 0;
}
