#include <bits/stdc++.h>
using namespace std;
int m, h, ans;
int main() {
  scanf("%d:%d", &h, &m);
  while (++ans) {
    if (h / 10 == m % 10 && h % 10 == m / 10) break;
    m++;
    if (m == 60) {
      m = 0;
      h++;
    }
    if (h == 24) h = 0;
  }
  cout << ans - 1;
  return 0;
}
